Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 22 Nov 2018, 07:12
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
mounting external drives and flash drives the easy way
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message

Joined: 06 Dec 2006
Posts: 364
Location: Queensland, Australia

PostPosted: Tue 29 Jun 2010, 21:56    Post subject:  mounting external drives and flash drives the easy way
Subject description: use disk labels... except they don't work by default in Puppy... here's how to fix it

I got fed up with the almost random way external drives' device names are assigned in Linux. It makes it very difficult to run scripts to do automated jobs on those drives because you have to be very careful that it is talking to the correct device -- a problem when the device name changes in different sessions.

When I used to use the Amiga (I still do from time to time) I could refer to drives via their device names, but it was simpler and easier to use a human-oriented label. That way the machine found the correct drive no matter where it was plugged in. I felt sure Linux must have such a capability. It does, but for some reason almost nobody seems to use it.

It is a special problem in Puppy because the mount command uses busybox by default. I've had a lot of problems with busybox in the past and have come to detest it. Oddly, Puppy also contains the full mount command (as mount-FULL) and this is how we can fix it.

NOTE: In the examples below I use my own external drive formatted to ext3 format, on /dev/sdb1 and my own label wd00. You should substitute your own particular device, its format, and a label of your own choosing. I find writing it this way is easier for people to follow.

I mounted the drive for a moment to check its device address first. Once I knew that I unmounted it again. You can use pmount to get that info without mounting and unmounting anything though.

Now that I know where the drive is connected, I can label it:
e2label /dev/sdb1 wd00
NOTE: e2label can't be used on vfat or ntfs drives. I don't know what command to use in that case. I'll add an item here when I find out.

Next I verified the label
blkid /dev/sdb1
It returned this:
/dev/sdb1: UUID="f3683b08-4b9b-4dc0-8a7a-817f40ce8dfe" SEC_TYPE="ext2" TYPE="ext3" LABEL="wd00"
Be careful to note the format of your drive (commonly ext2/ext3/ext4 for linux, or vfat/ntfs for MSWindows -- thumbdrives generally come preformatted to vfat). You can reformat external hard drives or thumbdrives using gparted, which also lets you label them. Note that e2label labels drives and partitions without problem, but gparted wants to delete the partition's contents in order to do so (at least in older versions).

Make a folder somewhere convenient. Use the command line or right-click the filelist in rox to make a new directory. (I choose to put it in /mnt, though you can use / if you want, and I notice Ubuntu has started using a new place called /media for mounting usb drives.) It can be named whatever I want, but it's best to give it the same name as the disklabel to simplify matters
mkdir /mnt/wd00

Now I can mount the drive by its label instead of the device name, but I can't use the normal Puppy "mount" because it uses busybox's mount, which doesn't recognise disklabels. Fortunately, as I mentioned earlier, Puppy also includes the full version of mount called appropriately, mount-FULL. Why doesn't Puppy use the full mount instead of busybox's broken one? I don't know. Can anybody answer this for me? Anyway, now I can mount the drive like this:
mount-FULL -t ext3 -L wd00 /mnt/wd00

Now I can easily access the drive by its label no matter what its device name:
ls /mnt/wd00

One problem remains though. I'd like the drive to be recognised automatically without having to give the long mount command every time I want to mount it. This requires adding an entry in the /etc/fstab file. Here is the line I added for mine:
LABEL=wd00   /mnt/wd00   ext3   defaults      0 0
You will need to read up on fstab to understand all the possibilities, but the LABEL=wd00 is obvious -- substitute whatever label you choose, then for the next part /mnt/wd00 substitute where you choose to mount it. The next bit gives the format type of the drive -- mine is ext3. You can give auto here and it should autodetect the type, but be careful, because if it is vfat it will try to mount it as old-style fat without long filenames, which is annoying, so if vfat you'll have to specify vfat.

Now I have to change Puppy's mount command to be able to use labels. This is pretty easy because in Puppy it is actually a script. You can do it one of 2 ways:


In case of problems make a backup of the mount script (call it mount-script). Load /bin/mount into a text editor (e.g. geany). Do not use a word processor! I edited the 3 places (two near the beginning and one near the end of the file) that refer to busybox so instead of saying busybox mount it says mount-FULL. The 3 lines I changed are:
[ ! $1 ] && exec busybox mount
  busybox mount $@
  busybox mount -r -t ntfs $CMDPRMS
So now they look like
[ ! $1 ] && exec mount-FULL
  mount-FULL $@
  mount-FULL -r -t ntfs $CMDPRMS
(I'm not sure if that last line should be changed, but I don't have any ntfs drives so am unable to test it.)


(My preferred choice.) If you don't have any Microsoft Windows ntfs drives you could simply rename the mount script as mount-script and make a link to mount-FULL called mount (easiest way is to right-click on mount-FULL, choose Link from the popup menu and call it mount). Now Puppy will use the proper mount program which avoids the mess of editing the mount script, but loses the nice ntfs handling done by Puppy programmers. It may still work fine with ntfs, but as I mentioned, I don't have any ntfs drives so can't test it.

Now after the change to fstab and the mount command I can simply click on the icon /mnt/wd00 and it will mount and open the disk no matter what USB port it is connected to. I've dragged the icon to my desktop for convenience.


I know it sounds like a lot to do, but that's only because I've discussed in detail each step. If you are advanced then it is simply a matter of
    * giving your drive a label with e2label <device> <label>
    * making a mount-point for the drive, perhaps in /mnt/<label>
    * mounting the drive using mount-FULL -t <format-type> -L <label> <mount-point>
    adding a line in fstab, in which case /bin/mount must be altered to use the proper mount command instead of busybox.

See? Easy. Smile

A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send private message Visit poster's website 

Joined: 14 Sep 2013
Posts: 1241
Location: Green Island baby!

PostPosted: Wed 09 Sep 2015, 17:46    Post subject:  

Thanks for that . It came in handy seehttp://murga-linux.com/puppy/viewtopic.php?p=863306#863306
Back to top
View user's profile Send private message Yahoo Messenger 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0581s ][ Queries: 11 (0.0134s) ][ GZIP on ]