新增一顆 SSD 硬碟來當做網頁資料存取。
1. 連接好 SSD 硬碟
[@more@]2. 分割 SSD 硬碟
# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6de07098.
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): p
Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 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: 0x6de07098
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-250069679, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-250069679, default 250069679):
Using default value 250069679
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3. 格式化 SSD 硬碟
# mkfs.ext4 /dev/sda1
mke2fs 1.42.5 (29-Jul-2012)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
7815168 inodes, 31258454 blocks
1562922 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
954 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
4. 查看 SSD 硬碟分割區的 UUID
# blkid
/dev/sda1: UUID=”31bcc29f-70a8-46b5-85ad-51b52a30501b” TYPE=”ext4″
/dev/mmcblk0p1: SEC_TYPE=”msdos” UUID=”4D17-5A3B” TYPE=”vfat”
/dev/mmcblk0p2: UUID=”1af97748-34b7-4a6e-a16d-29c409d9c367″ TYPE=”ext4″
5. 建立掛載的目錄
# mkdir /var/www
6. 修改 /etc/fstab
# cp /etc/fstab /etc/fstab.$(date +%F)
# vim /etc/fstab
加入下面一行
UUID=31bcc29f-70a8-46b5-85ad-51b52a30501b /var/www ext4 noatime,nodiratime,discard,defaults 0 1
7. 重新啟動電腦
# sync;sync;sync;reboot
8. 驗收成果
# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 947M 6.0G 14% /
/dev/root 7.3G 947M 6.0G 14% /
devtmpfs 486M 0 486M 0% /dev
tmpfs 98M 252K 97M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 195M 0 195M 0% /run/shm
/dev/sda1 118G 188M 112G 1% /var/www