You are not logged in.

#1 2008-02-01 11:35:42 am

nickca
Member
Registered: 2007-12-12
Posts: 53

So you've installed extra internal storage, now what? (Linux)

Now that you've installed extra internal storage, your OS needs a little configuring to use them properly. The USB drives, SDHC cards, etc. you've soldered in are permanent extra storage, unfortunately the OS is still treating them as removable USB sticks. This means that they won't always have the same device name across reboots, and if you're using GNOME or XFCE (dunno about KDE, sorry), they still show up on the desktop as removable drive icons. Here's how to fix that.

First, to give the devices persistent names and ensure they're mounted at boot, you need to add udev rules for them. Every device has certain unique identifiers, among them the serial number and the UUID. The serial number is unique to each drive, and the UUID is unique to each partition on each drive. To find out this information, open a terminal and, assuming you have a USB stick that is /dev/sdb (do "dmesg | grep sd" to determine which drive is which) and run "udevinfo -q env -n /dev/sdb1". You should see a bunch of information, among which are lines that look like this:

Code:

ID_SERIAL_SHORT=ATA_SILICONMOTION_SM223AC
ID_FS_UUID=48a1ece8-1bc9-42ad-b008-f46ebeb2edaf

Write all these down. The above is actually the info for my internal SSD, as this command will no longer work after you've set up the udev rules for your other drives. Now that you have the serial and UUID for the drive and partition, navigate to /etc/udev/rules.d (I'm using Ubuntu, this should be the same for Debian-based distros, others may vary) and create a file named 01-(yourname).rules (e.g. mine is named "01-nickca.rules"). You can actually name it whatever you want as long as it starts with 01- and ends with .rules. Here's my configuration, and the udev file I've set up:

8GB SDHC, never removed and mounted on /media/Documents
16GB internal USB, 15GB partition 1 for data, 1GB partition 2 for swap
16GB internal USB, single drive-spanning partition for data

And the udev file:

Code:

# Rules to ensure USB storage devices have persistent names and are mounted
# at boot.

# SD card reader
BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="146030377350", NAME="SDHC", OPTIONS+="last_rule", RUN+="/bin/mount /dev/SDHC" 

# Internal USB 1, partition 2 (swap)
BUS=="usb", KERNEL=="sd?2", SYSFS{serial}=="00000000002548", NAME="swap", OPTIONS+="last_rule", RUN+="/sbin/swapon /dev/swap"

# Internal USB 1, partition 1 (storage)
BUS=="usb", KERNEL=="sd?1", SYSFS{serial}=="00000000002548", NAME="USB16A", OPTIONS+="last_rule"

# Internal USB 2, partition 1 (storage)
BUS=="usb", KERNEL=="sd?1", SYSFS{serial}=="00000000003D46", NAME="USB16B", OPTIONS+="last_rule"

With this file, the SDHC is given the name /dev/SDHC, partiton 2 (swap) on USB stick A is /dev/swap, partition 1 (data) on USB stick A is  /dev/USB16A, and USB stick B is /dev/USB16B. The SDHC and swap are automatically mounted (the "RUN" directive). I'm using serial numbers here, UUIDs are probably possible, but I couldn't get them to work. The KERNEL directives for the USB sticks are used to differentiate between the swap and data partitions since the serial number applies to the whole drive. So if USB stick A is recognized as /dev/sdb at boot, the data partition is /dev/sdb1 and swap is /dev/sdb2, and these rules map them to /dev/USB16A and /dev/swap. If you've got just 1 partition on your USB drive, you can dispense with this and just use "KERNEL==sd*" like I did with the SDHC card. Finally, add lines like these to /etc/fstab:

Code:

# For the SDHC card
/dev/SDHC       /media/Documents        ext2    defaults,noatime        0      0

# For the swap
/dev/swap       swap    swap    defaults        0       0

I haven't added the other partitions as I'm setting them up in an LVM configuration and mounting it under /usr, which I haven't finished yet, but you get the idea.

Now that you've set this up, the drives will still appear on your desktop. Even the 1GB swap partition I made appears, which is obviously undesireable. GNOME and XFCE use a subsystem called HAL (hardware abstraction layer) to deal with removable drives and other peripherals such as cameras, MP3 players, etc. You might want them to appear, but if not, here's how to make your drives invisible to HAL. This is where the UUIDs you got eariler come into play, hopefully you wrote them down, since if you've added the udev rules and rebooted, you won't be able to get them with udevinfo anymore. If you need to get them again, comment out all the lines in your 01-(whatever).rules file and reboot. Anyway, UUIDs at the ready, edit the file /etc/hal/fdi/policy/preferences.fdi and add some lines that look like this:

Code:

  <device>
    <match key="volume.uuid" string="ff105bcd-9824-40bb-b661-493b1b6afdf6">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>

    <match key="volume.uuid" string="22d2c1a3-71cb-4b3f-a741-8231505fa545">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>

    <match key="volume.uuid" string="8dbfdbe8-3d9d-4cef-bcd0-17bfa5f5de7f">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>
  </device>

Add them at the end of the file above "</deviceinfo>". These are the uuids for my swap partition and the data partitions on the two USB drives. Now that you've added this, either reboot or run "/etc/init.d/hal restart" and restart X. Presto, the removable drive icons no longer show up as "16G removable drive" or what have you. Now your new USB drives are, more or less, treated like permanent drives by the OS. Remember, all this is an example from my system, your configuration will be totally different, except you can use the udev rule for the SDHC if you like as the serial number is the same in all eeePCs. Let me know if you have any questions.


eeePC 4G 7B - 1GB DDR667 RAM - Internal USB hub w/32GB (2x16GB) flash, Bluetooth, spare internal USB connection

Offline

 

#2 2008-02-01 2:05:40 pm

Jon Bradbury
Moderator
From: UK
Registered: 2007-09-20
Posts: 2568

Re: So you've installed extra internal storage, now what? (Linux)

Great info. Please create a WIKI entry!

Offline

 

#3 2008-02-01 6:59:53 pm

lotus49
Member
From: Yorkshire
Registered: 2008-01-27
Posts: 43

Re: So you've installed extra internal storage, now what? (Linux)

Thanks for this very useful information.

Although I am sure many people won't care, having the eee think an internally installed flash drive is removable is just the sort of thing that really irritates me even if it doesn't really make much difference in practice.

Offline

 

#4 2008-02-01 7:38:43 pm

Mjolinor
Senior Member
From: UK
Registered: 2008-01-14
Posts: 421

Re: So you've installed extra internal storage, now what? (Linux)

"vol_id /dev/sdXX"

will tell you the UUID if you forget to write it down.

Offline

 

#5 2008-02-01 10:09:15 pm

nickca
Member
Registered: 2007-12-12
Posts: 53

Re: So you've installed extra internal storage, now what? (Linux)

OK, I've created a wiki entry:

http://wiki.eeeuser.com/making_usb_stor … _permanent

Anyone, feel free to format this better if you wish, I just copy and pasted the forum post as I hate writing wiki articles with their bastardized pseudo-HTML, but all the information is there.


eeePC 4G 7B - 1GB DDR667 RAM - Internal USB hub w/32GB (2x16GB) flash, Bluetooth, spare internal USB connection

Offline

 

#6 2008-02-02 1:34:52 am

nickca
Member
Registered: 2007-12-12
Posts: 53

Re: So you've installed extra internal storage, now what? (Linux)

As an addendum that likely no one will need, when I set up my data partitions for use with LVM, the UUIDs changed and they started showing up on the desktop again. When I substituted the UUIDs I got by running "pvdisplay", they wouldn't work for some reason. So, I changed my HAL rules to this:

Code:

    <match key="block.device" string="/dev/swap">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>

    <match key="block.device" string="/dev/USB16A">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>

    <match key="block.device" string="/dev/USB16B">
      <merge key="volume.ignore" type="bool">true</merge>
    </match>

and that worked. It might be better to use block.device instead of volume.uuid anyway, but UUIDs will work for 99% of people and I don't want to rewrite the whole article. As an aside, you can find out all the keys you can use in HAL rules with the command "lshal".

EDIT: If you have two USB drives installed like I do and want to use them as one logical filesystem, the best way to do it is with LVM. Follow this guide to set it up:

http://www.howtoforge.com/linux_lvm

You could use software RAID0 or RAID5, but that will absolutely kill a flash device due to the extra writes involved. After you've set up LVM per the above guide, refer back to this thread and follow the information in my first post and this one.

Last edited by nickca (2008-02-02 1:44:07 am)


eeePC 4G 7B - 1GB DDR667 RAM - Internal USB hub w/32GB (2x16GB) flash, Bluetooth, spare internal USB connection

Offline

 

#7 2008-02-02 6:11:11 am

nickca
Member
Registered: 2007-12-12
Posts: 53

Re: So you've installed extra internal storage, now what? (Linux)

One last addendum if you're going to use LVM with internal USB sticks: for some reason, USB drives don't get mounted at boot automatically if you just put an entry in fstab as you'd expect, which is why I have the RUN directive in my udev rules. This also applies to your LVM volumes. Fortunately, you can add a udev rule to fix that as well. Here is my final udev ruleset with everything working and mounted at boot:

Code:

# Rules to ensure USB storage devices have persistent names and are mounted
# at boot.

# SD card reader
BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="146030377350", NAME="SDHC", OPTIONS+="last_rule", RUN+="/bin/mount /dev/SDHC" 

# Internal USB 1, partition 2 (swap)
BUS=="usb", KERNEL=="sd?2", SYSFS{serial}=="00000000002548", NAME="swap", OPTIONS+="last_rule", RUN+="/sbin/swapon /dev/swap"

# Internal USB 1, partition 1 (storage)
BUS=="usb", KERNEL=="sd?1", SYSFS{serial}=="00000000002548", NAME="USB16A", OPTIONS+="last_rule"

# Internal USB 2, partition 1 (storage)
BUS=="usb", KERNEL=="sd?1", SYSFS{serial}=="00000000003D46", NAME="USB16B", OPTIONS+="last_rule", RUN+="watershed sh -c '/sbin/lvm vgscan; /sbin/lvm vgchange -a y userfiles; /bin/mount /dev/userfiles/usr'"

And in fstab (I'm mounting it on a temporary mountpoint, eventually it will be my /usr):

Code:

# LVM volume on 2x16GB USB
/dev/userfiles/usr      /mnt/lvmtmp     ext2    rw,noatime      0       0

As you can see, I've added a RUN directive to the second USB device, which is the last volume in the LVM group. This loads the logical volume "usr" in the volume group "userfiles", substitute your different names accordingly.

There has to be an easier way to do this, but extensive googling hasn't revealed why USB drives don't mount automatically at boot. This is sort of an ugly workaround, but it works perfectly. Again, this is all under Ubuntu, on other distros you're on your own, but it won't be that much different as udev, LVM, HAL etc. works the same way everywhere.


eeePC 4G 7B - 1GB DDR667 RAM - Internal USB hub w/32GB (2x16GB) flash, Bluetooth, spare internal USB connection

Offline

 

#8 2008-02-04 1:32:27 pm

omne
Member
Registered: 2008-02-02
Posts: 12

Re: So you've installed extra internal storage, now what? (Linux)

Hello,
I have one sdhc 8G in my eeepc with eeexubuntu. I used to use the UUID in fstab but I tried your tric.
But I have a problem.
Can you hibernate / suspend with this rules ? Each time I tried, when I return, I have lost my sdcard and a e2fsck show me errors on the card.
How do you deal with this ?

Thank’s
Omne.

Offline

 

#9 2008-02-23 6:59:21 pm

Bokonon01
New member
Registered: 2008-02-23
Posts: 2

Re: So you've installed extra internal storage, now what? (Linux)

Awesome, awesome, awesome!  Exactly what I was looking for.  On the first try I caused an error, dumping me to a root shell on boot.  It turns out I forgot to remove the line where my SD card was mounted in the first place.  I found that pretty quick and now it looks like I'm all set.  Suspend/resume worked too.  Thanks a million!

Offline

 

#10 2009-02-05 5:33:37 am

faust_mateo
Member
From: LA
Registered: 2009-01-29
Posts: 18

Re: So you've installed extra internal storage, now what? (Linux)

Anyone know how to do this for Windows XP, All the step-by-step show how to do it too a SD/HC Card and I have a internal USB I'd like to have recognized as a mounted drive. TY in advance.


Asus 3ePC modded 701 4G, 2GB Ram, Win XP Home, 16GB SDHC, Touchscreen w/working Cam, USB controller w/2 Internal USB (1x32GB Internal USB & Internal Bluetooth) ~originally w/Linux , external USB Western Digi passport 320gb 2.5" SATA ( D smile for programs and storage. smile

Offline

 

Board footer

Powered by PunBB 1.2.15
© Copyright 2002–2005 Rickard Andersson