Bootable Linux USB stick: Difference between revisions

(Created page with "We regularly and successfully use USB sticks for courses where participants bring their own notebooks. The big benefit is that students learn Linux, and realize that they can...")
 
Line 22: Line 22:
# As for normal OS installation it matters if for the installation of the stick your computer is booted in BIOS mode (on newer machines "CSM enabled") --> you obtain a stick which boots BIOS systems, or if for the installation your computer is booted in EFI mode --> you obtain a stick which boots in EFI mode on newer computers and Macs
# As for normal OS installation it matters if for the installation of the stick your computer is booted in BIOS mode (on newer machines "CSM enabled") --> you obtain a stick which boots BIOS systems, or if for the installation your computer is booted in EFI mode --> you obtain a stick which boots in EFI mode on newer computers and Macs
# the SANdisk Extreme is the best stick we found; physically small sticks look nicer but are slow (even though they are called USB3)
# the SANdisk Extreme is the best stick we found; physically small sticks look nicer but are slow (even though they are called USB3)
# we always use the 64bit distro
# the FAT32 partition should be the first partition on the stick; 2GB is enough for us. Then comes the Linux partition, with 13.9GB, so that the sum of the two partitions is slightly below 16GB. The third partition is then a 16.1GB /data partition. This scheme has the advantage that the image of the stick can just as well be copied (with dd or better ddrescue) to a 16GB stick; the /data partition then does not fit and cannot be used on that stick, but the operating system will then work on the small stick just as well. This requires that the /data partition is not mounted automatically from /etc/fstab (i.e. it should be listed, but with the noauto option), but rather with a command like "mount /data &" from /etc/rc.local - because if the 16GB stick is booted, it will otherwise find a corrupt filesystem and the boot will fail, leaving you with a rudimentary shell prompt which only experts can recover from. Also this means that the image of the stick need only comprise the first 16GB (unless the /data partition already has something on it) - that makes it faster to copy it, and it is quite fast to re-create an empty /data partition after booting the stick.
# the FAT32 partition should be the first partition on the stick; 2GB is enough for us. Then comes the Linux partition, with 13.9GB, so that the sum of the two partitions is slightly below 16GB. The third partition is then a 16.1GB /data partition. This scheme has the advantage that the image of the stick can just as well be copied (with dd or better ddrescue) to a 16GB stick; the /data partition then does not fit and cannot be used on that stick, but the operating system will then work on the small stick just as well. This requires that the /data partition is not mounted automatically from /etc/fstab (i.e. it should be listed, but with the noauto option), but rather with a command like "mount /data &" from /etc/rc.local - because if the 16GB stick is booted, it will otherwise find a corrupt filesystem and the boot will fail, leaving you with a rudimentary shell prompt which only experts can recover from. Also this means that the image of the stick need only comprise the first 16GB (unless the /data partition already has something on it) - that makes it faster to copy it, and it is quite fast to re-create an empty /data partition after booting the stick.
# it is a good idea to give easy root access to the one user you create because certainly some packages will have to be installed or updated when the stick is in use
# it is a good idea to give easy root access to the one user you create because certainly some packages will have to be installed or updated when the stick is in use
# it is a good idea to save an image of the stick whenever you made a successful change; otherwise you might need to start from scratch if you mess something up.
# it is a good idea to save an image of the stick whenever you made a successful change; otherwise you might need to start from scratch if you mess something up.
# (if the installation not already does it for you) '''you should label the partitions and use the labels for mounting the partitions in /etc/fstab; don't use /dev/sda1 or the like because depending on the hardware it is booted on, after booting the stick, and depending on the actual hardware, the stick may be /dev/sdb or /dev/sdc !'''
# (if the installation not already does it for you) '''you should label the partitions and use the labels for mounting the partitions in /etc/fstab; don't use /dev/sda1 or the like because depending on the hardware it is booted on, after booting the stick, and depending on the actual hardware, the stick may be /dev/sdb or /dev/sdc !'''
1,330

edits