WenJunjie Blog

sysadmin

Disk Partition

| Comments

分区的目的

易用性 调优 安全 备份与恢复 稳定和效率 测试

/usr /var /tmp /boot / /home

  • nosuid - Do not set SUID/SGID access on this partition
  • nodev - Do not character or special devices on this partition
  • noexec - Do not set execution of any binaries on this partition
  • ro - Mount file system as readonly
  • quota - Enable disk quota

  • /home - Set option nosuid, and nodev with diskquota option

  • /usr - Set option nodev
  • /tmp - Set option nodev, nosuid, noexec option must be enabled

less /etc/fstab /dev/sda1 /home ext3 defaults,nosuid,nodev 1 2

mount -o remount, rw /data mount -o ro,remount /data mount -a fdisk -l df -h df -k mount

分区建议大小

centos 5.7

partition   web         db
/usr        30-50G      15-20G
/var        10-20G      10G
/tmp        8G          16G
swap        8G          16G
/           10G         10G
/boot       100M        100M
/home       10G         10G
/data       >           >

1T

#part /boot --fstype ext3 --onpart sda1
#part pv.3 --noformat --onpart sda3
#part swap --noformat --onpart sda2
#volgroup VolGroup00 --noformat --useexisting --pesize=32768 pv.3
#logvol /tmp --useexisting --fstype ext3 --name=LogVol03 --vgname=VolGroup00 --size=16384
#logvol /app --noformat --useexisting --fstype ext3 --name=LogVol04 --vgname=VolGroup00 --size=764800
#logvol / --useexisting --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=51200
#logvol /usr --useexisting --fstype ext3 --name=LogVol01 --vgname=VolGroup00 --size=51200
#logvol /var --useexisting --fstype ext3 --name=LogVol02 --vgname=VolGroup00 --size=51200

分区命令

大于2T的磁盘分区

parted /dev/sdb
mklabel gpt
mkpart
p
\n
0
-1
p
q

mkpart primary 0 -1
mkpart primary 0% 100%
mkpart primary 0 10000  #1000M


print
quit

partprobe

mkfs -t ext3 /dev/sdb1
mkfs.ext3 /dev/sdb1

小于或等于2T

fdisk -l
fdisk /dev/sdb
m n p 1 w
mkfs -t ext3 /dev/sdb1
mkdir /data
mount /dev/sdb1 /data

vim /etc/fstab
/dev/sdb1               /data                    ext3    defaults        1 2

[root@test ~]# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 243133.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243133, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-243133, default 243133): 
Using default value 243133

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

[root@wtest ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
244121600 inodes, 488241447 blocks
24412072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14900 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

硬盘顺序问题

sda sdb UUID LABEL

/sbin/e2label /dev/sda1 /data
vim /etc/fstab
LABEL=/data               /data                    ext3    defaults        1 2

查看driver label

e2label /dev/sda1

LVM管理

Comments