using usb storage on raspberry pi

Assuming the USB storage is on /dev/sda

To mount a USB stick / disk and make it writable for the default login pi

/usr/bin/sudo /bin/mount -t vfat -o uid=pi,gid=pi /dev/sda /mnt/usb/

To create a 512M file on the USB storage and use it as swap:

# create an empty swapfile
/bin/dd if=/dev/zero of=/mnt/usb/swapfile bs=1M count=512
# create a loop device
/usr/bin/sudo /sbin/losetup /dev/loop0 /mnt/usb/swapfile
# setup swap area
/usr/bin/sudo /sbin/mkswap /dev/loop0
# enable the swap
/usr/bin/sudo /sbin/swapon /dev/loop0

To remove the swap:

# disable swap
/usr/bin/sudo /sbin/swapoff /dev/loop0
# delete loop
/usr/bin/sudo /sbin/losetup -d /dev/loop0

Umount the USB storage:

/usr/bin/sudo /bin/umount /mnt/usb/

This entry was posted on on 7/15/2012 and Posted in . You can follow any any response to this entry through theAtom feed. You can leave a comments, .


Leave a response

  1. reggie 4 months later:

    where do i input this info? i’m new to linux and don’t know where to actually type this

  2. clarence 4 months later:

    You can input them via the console.