linux下安装新硬盘并加载使用手记
一、过程步骤1、#kudzu //检测新硬件,这一步必须!
2、#fdisk -l //查看是否找到新的硬盘,查看硬盘代号。
3、#fdisk /dev/sdb //为新硬盘分区,例如分成sdb1
#mkfs.ext3 /dev/sdb1 //把新硬盘格式化成ext3格式
4、#mkdir /disk2 //创建新的挂载点
5、#mount /dev/sdb1 /disk2/ //手动挂载分区,把硬盘挂到/disk2目录下。
6、#vi /etc/fstab
/dev/sdb1 /disk2 ext3 auto 1 2 //设置为开机自动挂载分区。
二、开工
2、
查看硬盘代号
# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0007d856
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1305 10281600 8e Linux LVM
Disk /dev/sdb: 2147 MB, 2147483648 bytes <=新硬盘
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/dm-0: 9395 MB, 9395240960 bytes
255 heads, 63 sectors/track, 1142 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x30307800
Disk /dev/dm-1 doesn't contain a valid partition table
3、fdisk 分区
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x623223a1.
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/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x623223a1
Device Boot Start End Blocks Id System
Command (m for help): n <=新建分区
Command action
e extended
p primary partition (1-4)
p <=新建主分区
Partition number (1-4): 1 <=分区号为1,即/dev/sdb1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): p <=显示分区信息
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x623223a1
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux
Command (m for help): w <=保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4、创建挂载点
# mkdir /disk2
# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0007d856
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1305 10281600 8e Linux LVM
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x623223a1
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux
Disk /dev/dm-0: 9395 MB, 9395240960 bytes
255 heads, 63 sectors/track, 1142 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x30307800
Disk /dev/dm-1 doesn't contain a valid partition table
# mke2fs -j /dev/sdb1
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5、设置为开机自动挂载分区
# vi /etc/fstab
/dev/sdb1 /disk2 ext3 auto 1 2
6、手动挂载分区
# mount /dev/sdb1 /disk2/
格式化分区使用mkfs命令,如“/sbin/mkfs -t ext3 /dev/hdb3”,其含义就是将分区hdb3格式化为EXT3的格式
ag:
mkfs -t ext3 /dev/hdb 就是将第2块硬盘全格式化 linux下为剩余空间分区并加载。(将还未分区的空余空间分区)
相关命令
fdisk /dev/sda
p
n
回车
回车
p
w <=保存退出
reboot
ls /dev
mkfs.ext3 /dev/sda9
vi /etc/fstab
/dev/sda9 /opt ext3 auto 1 2
操作截图
# df -h
Filesystem SizeUsed Avail Use% Mounted on
/dev/sda3 996M233M712M25% /
/dev/sda8 996M 34M911M 4% /tmp
/dev/sda7 3.9G 73M3.7G 2% /home
/dev/sda6 9.7G4.1G5.2G44% /var
/dev/sda5 9.7G580M8.7G 7% /usr
/dev/sda1 99M 12M 82M13% /boot
tmpfs 2.0G 02.0G 0% /dev/shm
# fdisk /dev/sda
The number of cylinders for this disk is set to 19457.
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)
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks IdSystem
/dev/sda1 * 1 13 104391 83Linux
/dev/sda2 14 1057 8385930 82Linux swap / Solaris
/dev/sda3 1058 1188 1052257+83Linux
/dev/sda4 1189 19457 146745742+ 5Extended
/dev/sda5 1189 2493 10482381 83Linux
/dev/sda6 2494 3798 10482381 83Linux
/dev/sda7 3799 4320 4192933+83Linux
/dev/sda8 4321 4451 1052226 83Linux
Command (m for help): n
First cylinder (4452-19457, default 4452): (起始地址直接回车)
Using default value 4452
Last cylinder or +size or +sizeM or +sizeK (4452-19457, default 19457): (终止地址直接回车)
Using default value 19457
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks IdSystem
/dev/sda1 * 1 13 104391 83Linux
/dev/sda2 14 1057 8385930 82Linux swap / Solaris
/dev/sda3 1058 1188 1052257+83Linux
/dev/sda4 1189 19457 146745742+ 5Extended
/dev/sda5 1189 2493 10482381 83Linux
/dev/sda6 2494 3798 10482381 83Linux
/dev/sda7 3799 4320 4192933+83Linux
/dev/sda8 4321 4451 1052226 83Linux
/dev/sda9 4452 19457 120535663+83Linux
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.
# ls /dev
bus loop4 parport3ram4 sda5 tty11tty26tty40tty55ttyS3 vcs2
consoleloop5 port ram5 sda6 tty12tty27tty41tty56urandom vcs3
core loop6 ppp ram6 sda7 tty13tty28tty42tty57usbdev1.1_ep00vcs4
cpu loop7 ptmx ram7 sda8 tty14tty29tty43tty58usbdev1.1_ep81vcs5
disk MAKEDEV pts ram8 sda9(有了)tty15tty3 tty44tty59usbdev2.1_ep00vcs6
fd mapper ram ram9 sg0 tty16tty30tty45tty6 usbdev2.1_ep81vcsa
full mcelog ram0 ramdiskshm tty17tty31tty46tty60usbdev3.1_ep00vcsa1
hpet md0 ram1 random snapshottty18tty32tty47tty61usbdev3.1_ep81vcsa2
initctlmem ram10 rawctl stderr tty19tty33tty48tty62usbdev4.1_ep00vcsa3
input net ram11 root stdin tty2 tty34tty49tty63usbdev4.1_ep81vcsa4
kmsg null ram12 rtc stdout tty20tty35tty5 tty7 usbdev4.2_ep00vcsa5
log nvram ram13 sda systty tty21tty36tty50tty8 usbdev4.2_ep01vcsa6
loop0 oldmem ram14 sda1 tty tty22tty37tty51tty9 usbdev4.2_ep81X0R
loop1 parport0ram15 sda2 tty0 tty23tty38tty52ttyS0usbdev4.2_ep82zero
loop2 parport1ram2 sda3 tty1 tty24tty39tty53ttyS1vcs
loop3 parport2ram3 sda4 tty10 tty25tty4 tty54ttyS2vcs1
# mkfs.ext3 /dev/sda9
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
15073280 inodes, 30133915 blocks
1506695 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
920 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.Use tune2fs -c or -i to override.
# mkdir /opt
#vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/home /home ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devptsgid=5,mode=6200 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sda9 /opt ext3 auto 1 2
重启系统
# df -h
Filesystem SizeUsed Avail Use% Mounted on
/dev/sda3 996M233M712M25% /
/dev/sda8 996M 34M911M 4% /tmp
/dev/sda7 3.9G 73M3.7G 2% /home
/dev/sda6 9.7G4.1G5.2G44% /var
/dev/sda5 9.7G580M8.7G 7% /usr
/dev/sda1 99M 12M 82M13% /boot
tmpfs 2.0G 02.0G 0% /dev/shm
/dev/sda9 114G188M108G 1% /opt
页:
[1]