Disks & File Systems Dick Gillman, ITSS 1/19/06 10:20:11 am docs/disks.sxi
IDE and SCSI most lower end systems come with IDE SCSI better performance choose system with SCSI for servers
Checklist for new disk attach it format it mount and share it
attach it Disks identified by controller number target, set by microswitch at the back or bottom partition, or slice also possible to have multiple disks on 1 SCSI slot c0t0d0s0 is controller 0, target 0, disk 0, slice 0 slice 2 refers to the whole disk avoid target 6, this is often the CD
Example solaris Filesystem Mounted on /dev/dsk/c0t0d0s0 / /dev/dsk/c0t0d0s3 /var /dev/dsk/c0t0d0s4 /usr/local /dev/dsk/c0t0d0s7 /local /dev/dsk/c0t2d0s2 /local2
Example Irix bisda susa $ df -kl Filesystem Type kbytes use avail %use Mounted on /dev/root xfs 1736000 1703048 32952 99 / /dev/dsk/dks0d2s7 xfs 862008 59540 802468 7 /local /dev/dsk/dks0d2s6 xfs 609600 341632 267968 57 /usr/share bisda susa $
Example Linux Filesystem Mounted on /dev/hda1 / /dev/hda2 /local /dev/hdb2 /local1
attach it check the machine can see the new disk electrically, Solaris probe-scsi probe-ide reboot the system with the reconfigure option, or solaris devfsadmin format to check that the operating system can see the new disk
Format detects disks # format Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/scsi@3/sd@0,0 1. c0t8d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/scsi@3/sd@8,0 2. c0t9d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/scsi@3/sd@9,0 3. c0t10d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/scsi@3/sd@a,0 4. c1t5d0 <SEAGATE-ST32155N-0532 cyl 4162 alt 2 hd 8 sec 126> /pci@1f,4000/scsi@4/sd@5,0 5. c1t9d0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133> /pci@1f,4000/scsi@4/sd@9,0 6. c1t10d0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133> /pci@1f,4000/scsi@4/sd@a,0 7. c1t11d0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133> /pci@1f,4000/scsi@4/sd@b,0 8. c1t12d0 <SUN9.0G cyl 4924 alt 2 hd 27 sec 133> /pci@1f,4000/scsi@4/sd@c,0 Specify disk (enter its number):
Format it - divide into partitions solaris format Specify disk (enter its number): 0 selecting c0t0d0 [disk formatted] Warning: Current Disk has mounted partitions. format> partition partition> print Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 2144-6498 6.00GB (4355/0/0) 12581595 1 swap wu 0-725 1.00GB (726/0/0) 2097414 2 backup wm 0-24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 var wm 726-2143 1.95GB (1418/0/0) 4096602 5 unassigned wm 0 0 (0/0/0) 0 6 unassigned wm 0 0 (0/0/0) 0 7 unassigned wm 6499-24619 24.96GB (18121/0/0) 52351569
format it divide into partitions linux fdisk [root@distro ~]# fdisk /dev/hda Command (m for help): p Disk /dev/hda: 80.0 GB, 80000000000 bytes 255 heads, 63 sectors/track, 9726 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 9726 78019672+ 8e Linux LVM Command (m for help):
mkfs creates a file system within a partition Solaris: friendly front end newfs inodes: newfs will guess how many inodes to allocate, depending on partition size; may have to explicitly increase this if many small files are anticipated can run fsck to check the integrity of the partition
mount & share the partitions create a mount point in the root directory, mkdir /diskname put an entry in /etc/fstab (/etc/vfstab Solaris), and mountall put an entry in /etc/exports (/etc/dfs/dfstab in Solaris), and shareall check the new partition can be mounted on another machine
Advanced filesystems journalling logical volumes mirrors RAID
Journalling keeps a record of uncommitted changes can repair itself after a crash no need to run fsck Solaris: logging option in /etc/vfstab
Logical Volumes filesystem spread over several disks
Mirrors duplicate a filesystem on another set of disks on another controller resilient to disk or controller faults can choose downtime, or hot swappable
Mirrors tom lvm $ df -kl Filesystem kbytes used avail capacity Mounted on /dev/md/dsk/d0 3101839 1665415 1374388 55% / /dev/md/dsk/d4 1021735 290444 669987 31% /var /dev/md/dsk/d7 58164733 55468137 2114949 97% /local tom lvm $ metastat -p d7 -m d17 d27 1 d17 1 1 c1t0d0s7 d27 1 1 c1t1d0s7 d4 -m d14 d24 1 d14 1 1 c1t0d0s4 d24 1 1 c1t1d0s4 d1 -m d11 d21 1 d11 1 1 c1t0d0s1 d21 1 1 c1t1d0s1 d0 -m d10 d20 1 d10 1 1 c1t0d0s0 d20 1 1 c1t1d0s0
Mirrors same data on disk A and disk B disk A and B should have the same geometry disk A and B should be partitioned identically the easy way: format A as you want it, open another window, and juggle disk B's partitioning the quick way: prtvtoc /dev/rdsk/c0t1d0s2 fmthard -s /dev/rdsk/c1t1d0s2
Redundant Array of Inexpensive Disks a set of disks that appear to be one disk configure to give better reliability or response, or greater capacity
Types of RAID RAID 0: spread the data evenly across the disks faster I/O no protection against failure RAID 1: mirroring: data is duplicated on another set of disks resilience to failure; better performance, as either drive can service a read request RAID 5: RAID 0 + parity faster I/O; resilience to failure
RAID 0
RAID1 (mirroring)
RAID5
Tricks of the Trade move directory structures onto new disks move all the data on a disk replace a root disk patch a disk
tar tar archives a load of files, or directories into one big file, which can then be untarred to the target disk handy for moving small or medium collections of files about but if you use tar to move a disk about, your tar file will be as big as your disk tar not suitable for moving whole disks
Copy data to new disk cd /sourcedir find. -depth -print cpio -pmud /destdir find. -depth -print cpio -pmud /net/biudx/destdir
Use FTP to copy data source system A ftp b cd /destdir bin put find. -depth -print cpio -oc pipe destination system B cd /destdir mknod pipe p chown susa pipe cpio -icdm < pipe & rm pipe
Replace failing root disk cd / ufsdump -f /net/biudx/local/data/biudy/root.ufs format (note the contents) engineer replaces biudy's failing disk boot cdrom -s format newfs /dev/rdsk/c0t0d0s0 mkdir /tmp/a; mount /dev/dsk/c0t0d0s0 /tmp/a mkdir /tmp/b mount /net/192.171.123.234/local/data/biudy /tmp/b cd /tmp/a; ufsrestore /tmp/b/root.ufs repeat for any other partitions on the failing disk
patch a SCSI disk check it is SCSI; ls -o /dev/dsk get relative block number from syslog umount /local10; fsck /dev/rdsk/c0t1d0s0 calculate Absolute Block Number; format > part > print to get start and end blocks of each partition format > repair > block number fsck /dev/rdsk/c0t1d0s0 do not sync; cache contents will be dodgy reboot