370 likes | 468 Views
Lecture 11: Sys Admin-A. Mounting Fragmentation. Mounting. I have files on a thumb drive (They’re incredibly important) I plug it in to my computer It’s booted into the finest Linux distro How do I actually get to my files?
E N D
Lecture 11: Sys Admin-A • Mounting • Fragmentation
Mounting • I have files on a thumb drive • (They’re incredibly important) • I plug it in to my computer • It’s booted into the finest Linux distro • How do I actually get to my files? • Assume my finest Linux distro isn’t set to auto-mount my thumb drive
Mounting • We need a mount point
Mounting • We need a mount point • mkdir -p /media/meh • Now we need to mount it
Mounting • We need a mount point • mkdir -p /media/meh • Now we need to mount it • mount /dev/sdb1 /media/meh
Mounting • We need a mount point • mkdir -p /media/meh • Now we need to mount it • mount /dev/sdb1 /media/meh • All done? • What about filesystem type?
Mounting • We need a mount point • mkdir -p /media/meh • Now we need to mount it • mount /dev/sdb1 /media/meh • All done? • What about filesystem type? • Other mount options?
Mounting • My thumb drive contains slides • I don’t want to do this every MFW • I want to tell Linux to mount it every time • How do I do that?
Mounting • My thumb drive contains slides • I don’t want to do this every MFW • I want to tell Linux to mount it every time • How do I do that? • /etc/fstab!
Mounting • Device by… • …name • …ID
Mounting • Mount points
Mounting • Filesystem type • ‘proc’ is special • ‘ntfs-3g’ is essentially just ‘ntfs’
Mounting • Options • There’s a bunch of them
Mounting • auto/noauto • Mount device at bootupvs don’t • exec/noexec • Allow execution of binaries/scripts from this partition vs don’t • ro/rw • Read only vs read/write • sync/async • Write files immediatelyvs allowing them to be written later • user/users/nouser • Allow anyone (those listed) to mount device vs only letting root mount it
Mounting • Lots more options! • suid/nosuid • attime • gid • umask • size • credentials • mode • dev/nodev
Mounting • defaults • rw (read/write) • suid (allow us to set user/group ID bits) • dev (treat data as block device) • exec • auto • nouser • async
Mounting • Dump • 0 Do not backup filesystem • 1 Backup the filesystem • It’s almost always 0
Mounting • fsck • “filesystem check” • Order of filesystems to check • 0 means to ignore the filesystem
Mounting • Mounting in Windows is a little more hands-off • Mount point is set • For us, we just see it in “My Computer” • What happens when my device doesn’t show up there?
Mounting • Mounting in Windows is a little more hands-off • Mount point is set • For us, we just see it in “My Computer” • What happens when my device doesn’t show up there? • Look at Disk Management!
Mounting • Many things are either familiar or obvious • Note that my linux partitions don’t have… • …a filesystem type (fat32, ntfs, ext3,…) • “Type” in Disk Management means something else • …drive letter
Fragmentation Dear Students, Please wait while the bearded man draws you pretty pictures on the board. They will help you. Sincererly, -RVH
Fragmentation • Recall our partition has: • inodes at the start • “data” blocks afterwards • Let’s assume that we have no data on the partition • Maybe it’s a thumb drive we just formatted
Fragmentation • When I create a file, I get a single inode and no data block. • When I first write some content to the file, I get a block of storage • Assume just one for now
Fragmentation • I then create several more files • They all need a block themselves • I finally go back to my original file and make it larger • E.g., I finished out my slides for a certain Wednesday lecture • Where did I just get a block at?
Fragmentation • I then create several more files • They all need a block themselves • I finally go back to my original file and make it larger • E.g., I finished out my slides for a certain Wednesday lecture • Where did I just get a block at? • Why isn’t it next to the other one?
Fragmentation • My file is now scattered all over the partition • This is external fragmentation • How can I fix this? • I need to rearrange my files • Have to be careful in how I do this • We have tools • “Defragmenters”
Fragmentation • “Defragmenters” usually only do external fragmentation. • So what’s internal fragmentation?
Fragmentation • “Defragmenters” usually only do external fragmentation. • So what’s internal fragmentation? • I must reserve at least one block • If block is 128KB, then I just got 128KB • Assume my file is 4KB • My file wastes space!
Fragmentation • How do we fix this?
Fragmentation • How do we fix this? • Leave it alone? • Put multiple files into one block? • Reduce block size?
Fragmentation • How do we fix this? • Leave it alone? • Easy to do • Wastes space • Put multiple files into one block? • Reduce block size?
Fragmentation • How do we fix this? • Leave it alone? • Easy to do • Wastes space • Put multiple files into one block? • Saves space • More overhead • Reduce block size?
Fragmentation • How do we fix this? • Leave it alone? • Easy to do • Wastes space • Put multiple files into one block? • Saves space • More overhead • Reduce block size? • Superblock settings were chosen for performance. Usually undesirable to change this
Fragmentation • How do we fix this? • Leave it alone? • Easy to do • Wastes space • Put multiple files into one block? • Saves space • More overhead • Reduce block size? • Superblock settings were chosen for performance. Usually undesirable to change this