3

How to mount second partition on the same USB disk where Live Ubuntu was installed?

I was using dd to create a live USB.

I have created second VFAT partition using fdisk and formatted it using mkfs.ext2.

When I try to run "sudo mount /dev/sda2 /mnt" I get an error: /dev/sda2 already mounted or /mnt is busy.

It might be because /dev/sda (whole drive, not partition) is already mounted on /cdrom with type iso9660.

How do I overcome this, I need to be able to permanenty store some files on second partition.

4

The problem is that /dev/sda contains /dev/sda2. This would be a severe obstacle if both should be mounted as read-write filesystems. But in your case the ISO 9660 in /dev/sda (also in /dev/sda1) is read-only. So there will be no fighting of filesystems.

The normally correct way to have both filesystems mounted would be to umount /dev/sda and to mount /dev/sda1 instead. It does not overlap with /dev/sda2. So mount(8) will perceive no problem

But if the running system depends on files in the ISO 9660 filesystem, it might not be possible to umount it. In this case there remains the backdoor of using a loop device like /dev/loop0. Such a device is based on a data file or block device file. It acts as block device. See man losetup(8) for details.

mount(8) offers the convenience option "loop". So this should work although /dev/sda is already mounted:

mount -o loop /dev/sda2 /your/mount/directory

Luckily mount(8) is too stupid to recognize the overlapping although it then lists the partition device as mounted rather than the loop device.


/dev/sdc on /mnt/iso type iso9660 (ro,relatime)
/dev/sdc2 on /mnt/fat type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)

So this trick might cease to work in future ... :( (But maybe it also gets smart enough to recognize that the overlapping is harmless.)

  • +1 This is a good solution, that works on drives with cloned systems from iso files. (I tested it with Ubuntu 17.10 and and an extra partition with the ext4 file system. It works well for storage, but I could not make the live system use it for persistence.) – sudodus Dec 7 '17 at 18:52
1

I have not had success modifying partitions on a ISO 9660 drive that was made using Startup Disk Creator or Rufus.

However if you use mkusb to make the drive you will get a small FAT32 boot partition, an ISO 9660 OS partition, a ext4 casper-rw persistence partition and a NTFS data partition, (if requested).

You can then delete the casper-rw partition, if you don't need persistence, and expand or reformat the NTFS partition to suit your needs.

  • Will try it when get back from work. If I understood correctly, mkusb would write my custom ISO file to a USB drive and make NTFS data partition "mountable"? I have no trouble creating new partition by hand, it looks to me the problem is Ubuntu mounting enter device /dev/sda instead of one partition /dev/sda1 – kometonja Dec 6 '17 at 13:52
  • 1
    Solved it easily by mounting it as a loop device, please have a look at my answer. – kometonja Dec 7 '17 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.