SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


redhatsimplepartitioning
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
redhatsimplepartitioning [2014/03/18 22:00]
sjoerd
redhatsimplepartitioning [2014/03/18 22:15] (current)
sjoerd
Line 14: Line 14:
 Partitions are created using fdisk. Since fdisk is by default cylinder bound and red hat is not, you should ALWAYS start fdisk using the -cu option. Partitions are created using fdisk. Since fdisk is by default cylinder bound and red hat is not, you should ALWAYS start fdisk using the -cu option.
  
 +This is how I created a new simple partition on a new disk:
 +<​code>​
 +[root@localhost ~]# fdisk -cu /dev/sdb
 +Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 +Building a new DOS disklabel with disk identifier 0xe2173873.
 +Changes will remain in memory only, until you decide to write them.
 +After that, of course, the previous content won't be recoverable.
  
 +Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  
 +Command (m for help): n
 +Command action
 +   ​e ​  ​extended
 +   ​p ​  ​primary partition (1-4)
 +p
 +Partition number (1-4): 1
 +First sector (2048-10485759,​ default 2048):
 +Using default value 2048
 +Last sector, +sectors or +size{K,​M,​G} (2048-10485759,​ default 10485759): +1G
  
 +Command (m for help): p
  
 +Disk /dev/sdb: 5368 MB, 5368709120 bytes
 +255 heads, 63 sectors/​track,​ 652 cylinders, total 10485760 sectors
 +Units = sectors of 1 * 512 = 512 bytes
 +Sector size (logical/​physical):​ 512 bytes / 512 bytes
 +I/O size (minimum/​optimal):​ 512 bytes / 512 bytes
 +Disk identifier: 0xe2173873
 +
 +   ​Device Boot      Start         ​End ​     Blocks ​  ​Id ​ System
 +/​dev/​sdb1 ​           2048     ​2099199 ​    ​1048576 ​  ​83 ​ Linux
 +
 +Command (m for help): w
 +The partition table has been altered!
 +
 +Calling ioctl() to re-read partition table.
 +Syncing disks.
 +</​code>​
 +
 +> Note that if you would do this on the system disk you would get a warning that the kernel can't reread the partition table. Red hats supported way to solve this is rebooting the system. You could also issue this command which works fine but is not supported:
 +<​code>​
 +partx -a /dev/sda
 +</​code>​
 +
 +Now the partition is ready for creating a filesystem on it.
 +
 += Create a FileSystem =
 +
 +You can create a filesystem very easy by issuing this command:
 +<​code>​
 +mkfs -t ext4 /dev/sdb1
 +</​code>​
 +
 +This can also be done like this:
 +<​code>​
 +mkfs.ext4 /dev/sdb1
 +</​code>​
 +
 +Now you need to mount the filesystem.
 +
 += Mount a FileSystem =
 +To mount a filesystem you first need a mountpoint, for example /data
 +<​code>​
 +mkdir /data
 +</​code>​
 +
 +Now add the filesystem to /etc/fstab so it will mount automatically every time the system boots. For that you need the blockid/​UUID of the device:
 +<​code>​
 +[root@localhost ~]# blkid /dev/sdb1
 +/dev/sdb1: UUID="​692571db-cd24-4b41-80bd-73f595f70a17"​ TYPE="​ext4"​
 +</​code>​
 +
 +Now add it to /etc/fstab:
 +<​code>​
 +[root@localhost ~]# vim /etc/fstab
 +[root@localhost ~]# cat /etc/fstab
 +
 +#
 +# /etc/fstab
 +# Created by anaconda on Mon Mar 17 02:25:20 2014
 +#
 +# Accessible filesystems,​ by reference, are maintained under '/​dev/​disk'​
 +# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
 +#
 +UUID=57d2527c-66f3-46d8-a7b5-dd45be6169ab /                       ​ext4 ​   defaults ​       1 1
 +UUID=be15d7c6-f4bf-4b0c-8ebb-a86aeb453ce8 /boot                   ​ext4 ​   defaults ​       1 2
 +UUID=8f724c22-a198-4cf5-a58a-4aca739faeee swap                    swap    defaults ​       0 0
 +tmpfs                   /​dev/​shm ​               tmpfs   ​defaults ​       0 0
 +devpts ​                 /​dev/​pts ​               devpts ​ gid=5,​mode=620 ​ 0 0
 +sysfs                   /​sys ​                   sysfs   ​defaults ​       0 0
 +proc                    /proc                   ​proc ​   defaults ​       0 0
 +UUID=692571db-cd24-4b41-80bd-73f595f70a17 /data ext4    defaults ​       1 2
 +</​code>​
 +
 +> Note that the 1 at the end of the line means it should be added to dump created backups, and the second one means it should be verified during startup. ​
 +
 +Now you can mount and verify the mount like this:
 +<​code>​
 +[root@localhost ~]# mount /data
 +[root@localhost ~]# mount
 +/dev/sda2 on / type ext4 (rw)
 +proc on /proc type proc (rw)
 +sysfs on /sys type sysfs (rw)
 +devpts on /dev/pts type devpts (rw,​gid=5,​mode=620)
 +tmpfs on /dev/shm type tmpfs (rw,​rootcontext="​system_u:​object_r:​tmpfs_t:​s0"​)
 +/dev/sda1 on /boot type ext4 (rw)
 +none on /​proc/​sys/​fs/​binfmt_misc type binfmt_misc (rw)
 +vmware-vmblock on /​var/​run/​vmblock-fuse type fuse.vmware-vmblock (rw,​nosuid,​nodev,​default_permissions,​allow_other)
 +/dev/sdb1 on /data type ext4 (rw)
 +</​code>​
 +
 +Or you could simply mount all filesystems with {{{mount -a}}}
  
  
Line 28: Line 136:
 [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host1/​scan [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host1/​scan
 [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host2/​scan [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host2/​scan
-[root@localhost ~]# echo "​1"​ > /​sys/​class/​fc_host/​host/​issue_lip +
--bash: /​sys/​class/​fc_host/​host/​issue_lip:​ No such file or directory+
 [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host0/​scan [root@localhost ~]# echo "- - -" > /​sys/​class/​scsi_host/​host0/​scan
 +
 [root@localhost ~]# fdisk -cul [root@localhost ~]# fdisk -cul
  
Line 54: Line 162:
 </​code>​ </​code>​
  
 +> Note that I don't know on which host# the disk was assigned so I scanned a few...
  
 {{tag>​linux redhat storage}} {{tag>​linux redhat storage}}
redhatsimplepartitioning.txt · Last modified: 2014/03/18 22:15 by sjoerd