磁盘
硬盘--》常用的硬盘都是磁盘
====
存储设备
1.磁盘
2.u盘
3.磁带
4.光盘
5. ssd(固态硬盘)
能存数据的设备,简称存储设备
====
品牌
seagate 希捷
western digital 西部数据(wd)
三星
东芝(toshiba)
====
希捷Barracuda 1TB 7200转 64MB 单碟(ST1000DM003)
所属:
希捷 Barracuda 7200转系列
硬盘容量:1000GB
适用类型:台式机
接口类型:SATA3.0
转速:7200rpm (每分钟)
缓存:64MB
接口速率:6Gb/秒 (i/o)input output
硬盘尺寸:3.5英寸
====
硬盘接口类型
IDE---》已经淘汰了
SCSI
光纤通道(fiber channel)FC
SATA --》比较常见(配电脑都是这种) 串口
usb (3.0和2.0)
SAS (scsi和sata的混合技术)
====
固态硬盘价格贵
数据库服务器为了提高性能(i/o)
固态硬盘---》读写速度快
====
装系统也愿意使用固态硬盘--》速度
====
磁盘的物理结构
磁道(track) 63个sector
扇区(sector) 512字节
柱面(cylinder)
磁头(head)
===
15000转/分
硬盘容量:600GB
接口类型:SAS2
转速:15000转/分
缓存:16MB
接口速率:6Gb/s
平均寻道时间:3.4/3.9ms
工作功耗:16.31W
平均无故障时间:160万小时
盘体尺寸:3.5英寸
盘片数量:4
=====
平均访问时间=平均寻道时+平均等待时间(转速有关系)
=====
硬盘---》内存---》cpu
缓存的作用是:加快访问速度
=====
创建分区---》格式化---》挂载使用
Units = cylinders of 16065 * 512 = 8225280 bytes
一个柱面的大小=磁头数*扇区数*扇区的大小(512字节)
=====
分区:
主分区
扩展分区
逻辑分区
=====
http://dngood.blog.51cto.com/446195/647702/
MBR与GPT分区格式
MBR
MBR(Master Boot Record)主引导记录
4个主分区、扩展分区占一个主分区的位置
最大只能建立2TB大小的分区
最多一个扩展分区
扩展分区不能直接用来存数据,不能格式化
主分区、逻辑分区可以用来存数据
=======
编号:
1-4主分区使用
逻辑分区的编号大于等于5(从5开始)
====
验证4个分区
一个扩展分区
逻辑分区的编号从5
====
1.创建分区
[root@localhost ~]# fdisk -l 查看磁盘的分区情况
[root@localhost ~]# fdisk /dev/sdb
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-10443, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): +10G #指定分区的大小
Command (m for help): p 输出
Disk /dev/sdb: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x38913320
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
Command (m for help): w 退出并且保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
==
2.格式化
[root@localhost ~]# mkfs.ext4 /dev/sdb1 格式化sdb1这个分区
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655776 inodes, 2622603 blocks
131130 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2688548864
81 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]#
===
3.新建挂载目录
mkdir /music 新建挂载目录
4.挂载使用
mount /dev/sdb1 /music 挂载使用新的分区
=====
cd /music
===
复制些文件过去,测试
====
练习:
新建一个分区在/dev/sdb上,分区类型为主分区,大小20G 格式化为ext4文件系统,挂载到/movie
从10.0.0.253的software/mplayer目录下载电影xiyou.rmvb存放到/movie目录下
====
1.
新装一个系统, 观察grub、mbr
分区与文件系统的挂载对应关系
/boot
/
swap
/mail
/www
/home
2.
fdisk /dev/sdb
/www
/mail
/data
/mp3
/usb
partprobe
mkfs.ext4
mount
df -hT
umount
3.
无人值守install, 在文件中指定分区信息
================
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038216 14162292 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68636 1897524 4% /music
[root@lichao520 ~]#
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@lichao520 ~]# ls /dev/sdb*
/dev/sdb /dev/sdb2 /dev/sdb4 /dev/sdb6
/dev/sdb1 /dev/sdb3 /dev/sdb5
[root@lichao520 ~]# mkfs.ext4 /dev/sdb7
mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/sdb7 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
[root@lichao520 ~]#
========
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038208 14162300 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68636 1897524 4% /music
[root@lichao520 ~]# umount /music/
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038208 14162300 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
[root@lichao520 ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Error: Invalid partition table - recursive partition on /dev/sr0.
[root@lichao520 ~]# ls /dev/sdb*
/dev/sdb /dev/sdb2 /dev/sdb4 /dev/sdb6 /dev/sdb8
/dev/sdb1 /dev/sdb3 /dev/sdb5 /dev/sdb7
[root@lichao520 ~]#
===
partprobe--》让linux kernel重新读取硬盘的分区表,并且创建分区的设备文件,只有有了设备文件,才能进行格式化,再去挂载。
====
安装ntfs-3g软件,挂载ntfs文件系统,移动硬盘
[root@teacher web]# lftp 10.0.2.253
lftp 10.0.2.253:~> cd software/
lftp 10.0.2.253:/software> get ntfs-3g_ntfsprogs-2011.4.12.tgz
1126704 bytes transferred
lftp 10.0.2.253:/software> quit
====
备份mbr
原则:最好是备份后将文件拷贝到其他的电脑
[root@lichao520 music]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038220 14162288 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68640 1897520 4% /music
[root@lichao520 music]#
备份到本机的另外一块磁盘里
[root@lichao520 music]# dd if=/dev/sda of=/music/sda-mbr.bak bs=512 count=1
[root@lichao520 music]# pwd
/music
[root@lichao520 music]# ls
a bc lost+found passwd sda-mbr.bak
备份到其他的机器
[root@lichao520 music]# scp sda-mbr.bak 10.0.0.253:/root/
welcome teacher's computer
root@10.0.0.253's password:
sda-mbr.bak 100% 512 0.5KB/s 00:00
[root@lichao520 music]#
[root@lichao520 music]# hexdump -C sda-mbr.bak 查看备份mbr里的内容,以16进制和asc字母显示
==
破坏mbr
[root@lichao520 music]# dd if=/dev/zero of=/dev/sda bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000237891 s, 2.2 MB/s
[root@lichao520 music]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
===
营救模式
1.可以放入光盘到光驱,从光盘启动。或者从网络引导进入营救模式
2.从备份磁盘里还原mbr,或者从网络的备份中还原mbr
=====
全局唯一标识分区表(GUID Partition Table,缩写:GPT)是一个实体硬盘的分区结构。它是EFI(可扩展固件接口标准)的一部分,用来替代BIOS中的主引导记录分区表。但因为MBR分区表不支持容量大于2.2TB(2.2 × 1012字节)的分区,所以也有一些BIOS系统为了支持大容量硬盘而用GPT分区表取代MBR分区表。
在MBR硬盘中,分区信息直接存储于主引导记录(MBR)中(主引导记录中还存储着系统的引导程序)。但在GPT硬盘中,分区表的位置信息储存在GPT头中。但出于兼容性考虑,硬盘的第一个扇区仍然用作MBR,之后才是GPT头。
GPT磁盘分区样式支持最大卷为18 EB(Exabytes)并且每磁盘的分区数没有上限,只受到操作系统限制(由于分区表本身需要占用一定空间,最初规划硬盘分区时,留给分区表的空间决定了最多可以有多少个分区,IA-64版Windows限制最多有128个分区
==
http://dngood.blog.51cto.com/446195/647702/
===
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1
[root@lichao520 ~]# fdisk -l /dev/sdc
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdc: 2190.4 GB, 2190433320960 bytes
255 heads, 63 sectors/track, 266305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 1 266306 2139095039+ ee GPT
[root@lichao520 ~]#
=====
parted工具比fdisk工具分区危险,因为分区的时候直接生效,不能撤销。fdisk可以退出不保存。
====
练习:
1.添加2块磁盘,大小为50G和100G
2.将50G的磁盘分成2个主分区,大小分别为10G和20G和1个扩展分区,扩展分区下划分2个逻辑分区,大小分别为5G和15G
3.然后将4个分区都格式化为ext4文件系统,新建挂载目录,具体挂载如下
10G----》/mail
20G----》/software
5G----》/movie
15G---》/photo
4.将100G的磁盘的分区表采用GPT方式,新建2个分区大小分别为40G和60G
5.然后格式化为ext4文件系统,新建挂载目录,具体挂载如下:
40G ----》/ftp
60G ---》/www
=====
[root@teacher ftp]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@teacher ftp]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
PREFIX=16
DNS1=8.8.8.8
TYPE=Ethernet
HWADDR=00:30:67:f2:10:cf
USERCTL=no
IPV6INIT=no
IPADDR=10.0.2.253
NETMASK=255.255.0.0
[root@teacher ftp]#
===
(parted) mkpart movie 20001 60000
Warning: WARNING: the kernel failed to re-read the partition table on
/dev/sdc (Device or resource busy). As a result, it may not reflect
all of your changes until after reboot.
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 2190GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 3000MB 2999MB ext4 music
2 3001MB 10.0GB 6999MB ext4 m
3 10.0GB 20.0GB 10000MB u
4 20.0GB 60.0GB 40.0GB movie
(parted) quit
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1 /dev/sdc2
[root@lichao520 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 ext4 18G 2.9G 14G 18% /
tmpfs tmpfs 186M 260K 186M 1% /dev/shm
/dev/sda1 ext4 485M 35M 426M 8% /boot
/dev/sr0 iso9660 2.9G 2.9G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdc2 ext4 6.5G 143M 6.0G 3% /m
[root@lichao520 ~]# umount /m 卸载
[root@lichao520 ~]# partprobe /dev/sdc 重新读取分区表,生存设备文件
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1 /dev/sdc2 /dev/sdc3 /dev/sdc4
[root@lichao520 ~]#
===
安装系统的时候,到底分多少个分区。
/ 根据实际情况,尽可能的大些
swap 4G
/boot 500M
==
/
swap
/home
/boot
===
c--》系统
d--》软件
e--》文档
f--》娱乐
===
硬盘--》常用的硬盘都是磁盘
====
存储设备
1.磁盘
2.u盘
3.磁带
4.光盘
5. ssd(固态硬盘)
能存数据的设备,简称存储设备
====
品牌
seagate 希捷
western digital 西部数据(wd)
三星
东芝(toshiba)
====
希捷Barracuda 1TB 7200转 64MB 单碟(ST1000DM003)
所属:
希捷 Barracuda 7200转系列
硬盘容量:1000GB
适用类型:台式机
接口类型:SATA3.0
转速:7200rpm (每分钟)
缓存:64MB
接口速率:6Gb/秒 (i/o)input output
硬盘尺寸:3.5英寸
====
硬盘接口类型
IDE---》已经淘汰了
SCSI
光纤通道(fiber channel)FC
SATA --》比较常见(配电脑都是这种) 串口
usb (3.0和2.0)
SAS (scsi和sata的混合技术)
====
固态硬盘价格贵
数据库服务器为了提高性能(i/o)
固态硬盘---》读写速度快
====
装系统也愿意使用固态硬盘--》速度
====
磁盘的物理结构
磁道(track) 63个sector
扇区(sector) 512字节
柱面(cylinder)
磁头(head)
===
15000转/分
硬盘容量:600GB
接口类型:SAS2
转速:15000转/分
缓存:16MB
接口速率:6Gb/s
平均寻道时间:3.4/3.9ms
工作功耗:16.31W
平均无故障时间:160万小时
盘体尺寸:3.5英寸
盘片数量:4
=====
平均访问时间=平均寻道时+平均等待时间(转速有关系)
=====
硬盘---》内存---》cpu
缓存的作用是:加快访问速度
=====
创建分区---》格式化---》挂载使用
Units = cylinders of 16065 * 512 = 8225280 bytes
一个柱面的大小=磁头数*扇区数*扇区的大小(512字节)
=====
分区:
主分区
扩展分区
逻辑分区
=====
http://dngood.blog.51cto.com/446195/647702/
MBR与GPT分区格式
MBR
MBR(Master Boot Record)主引导记录
4个主分区、扩展分区占一个主分区的位置
最大只能建立2TB大小的分区
最多一个扩展分区
扩展分区不能直接用来存数据,不能格式化
主分区、逻辑分区可以用来存数据
=======
编号:
1-4主分区使用
逻辑分区的编号大于等于5(从5开始)
====
验证4个分区
一个扩展分区
逻辑分区的编号从5
====
1.创建分区
[root@localhost ~]# fdisk -l 查看磁盘的分区情况
[root@localhost ~]# fdisk /dev/sdb
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-10443, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): +10G #指定分区的大小
Command (m for help): p 输出
Disk /dev/sdb: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x38913320
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
Command (m for help): w 退出并且保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
==
2.格式化
[root@localhost ~]# mkfs.ext4 /dev/sdb1 格式化sdb1这个分区
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655776 inodes, 2622603 blocks
131130 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2688548864
81 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]#
===
3.新建挂载目录
mkdir /music 新建挂载目录
4.挂载使用
mount /dev/sdb1 /music 挂载使用新的分区
=====
cd /music
===
复制些文件过去,测试
====
练习:
新建一个分区在/dev/sdb上,分区类型为主分区,大小20G 格式化为ext4文件系统,挂载到/movie
从10.0.0.253的software/mplayer目录下载电影xiyou.rmvb存放到/movie目录下
====
1.
新装一个系统, 观察grub、mbr
分区与文件系统的挂载对应关系
/boot
/
swap
/www
/home
2.
fdisk /dev/sdb
/www
/data
/mp3
/usb
partprobe
mkfs.ext4
mount
df -hT
umount
3.
无人值守install, 在文件中指定分区信息
================
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038216 14162292 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68636 1897524 4% /music
[root@lichao520 ~]#
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@lichao520 ~]# ls /dev/sdb*
/dev/sdb /dev/sdb2 /dev/sdb4 /dev/sdb6
/dev/sdb1 /dev/sdb3 /dev/sdb5
[root@lichao520 ~]# mkfs.ext4 /dev/sdb7
mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/sdb7 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
[root@lichao520 ~]#
========
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038208 14162300 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68636 1897524 4% /music
[root@lichao520 ~]# umount /music/
[root@lichao520 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038208 14162300 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
[root@lichao520 ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
Error: Invalid partition table - recursive partition on /dev/sr0.
[root@lichao520 ~]# ls /dev/sdb*
/dev/sdb /dev/sdb2 /dev/sdb4 /dev/sdb6 /dev/sdb8
/dev/sdb1 /dev/sdb3 /dev/sdb5 /dev/sdb7
[root@lichao520 ~]#
===
partprobe--》让linux kernel重新读取硬盘的分区表,并且创建分区的设备文件,只有有了设备文件,才能进行格式化,再去挂载。
====
安装ntfs-3g软件,挂载ntfs文件系统,移动硬盘
[root@teacher web]# lftp 10.0.2.253
lftp 10.0.2.253:~> cd software/
lftp 10.0.2.253:/software> get ntfs-3g_ntfsprogs-2011.4.12.tgz
1126704 bytes transferred
lftp 10.0.2.253:/software> quit
====
备份mbr
原则:最好是备份后将文件拷贝到其他的电脑
[root@lichao520 music]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18121032 3038220 14162288 18% /
tmpfs 189948 264 189684 1% /dev/shm
/dev/sda1 495844 35002 435242 8% /boot
/dev/sr0 3027366 3027366 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdb5 2071384 68640 1897520 4% /music
[root@lichao520 music]#
备份到本机的另外一块磁盘里
[root@lichao520 music]# dd if=/dev/sda of=/music/sda-mbr.bak bs=512 count=1
[root@lichao520 music]# pwd
/music
[root@lichao520 music]# ls
a bc lost+found passwd sda-mbr.bak
备份到其他的机器
[root@lichao520 music]# scp sda-mbr.bak 10.0.0.253:/root/
welcome teacher's computer
root@10.0.0.253's password:
sda-mbr.bak 100% 512 0.5KB/s 00:00
[root@lichao520 music]#
[root@lichao520 music]# hexdump -C sda-mbr.bak 查看备份mbr里的内容,以16进制和asc字母显示
==
破坏mbr
[root@lichao520 music]# dd if=/dev/zero of=/dev/sda bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000237891 s, 2.2 MB/s
[root@lichao520 music]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
===
营救模式
1.可以放入光盘到光驱,从光盘启动。或者从网络引导进入营救模式
2.从备份磁盘里还原mbr,或者从网络的备份中还原mbr
=====
全局唯一标识分区表(GUID Partition Table,缩写:GPT)是一个实体硬盘的分区结构。它是EFI(可扩展固件接口标准)的一部分,用来替代BIOS中的主引导记录分区表。但因为MBR分区表不支持容量大于2.2TB(2.2 × 1012字节)的分区,所以也有一些BIOS系统为了支持大容量硬盘而用GPT分区表取代MBR分区表。
在MBR硬盘中,分区信息直接存储于主引导记录(MBR)中(主引导记录中还存储着系统的引导程序)。但在GPT硬盘中,分区表的位置信息储存在GPT头中。但出于兼容性考虑,硬盘的第一个扇区仍然用作MBR,之后才是GPT头。
GPT磁盘分区样式支持最大卷为18 EB(Exabytes)并且每磁盘的分区数没有上限,只受到操作系统限制(由于分区表本身需要占用一定空间,最初规划硬盘分区时,留给分区表的空间决定了最多可以有多少个分区,IA-64版Windows限制最多有128个分区
==
http://dngood.blog.51cto.com/446195/647702/
===
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1
[root@lichao520 ~]# fdisk -l /dev/sdc
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdc: 2190.4 GB, 2190433320960 bytes
255 heads, 63 sectors/track, 266305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 1 266306 2139095039+ ee GPT
[root@lichao520 ~]#
=====
parted工具比fdisk工具分区危险,因为分区的时候直接生效,不能撤销。fdisk可以退出不保存。
====
练习:
1.添加2块磁盘,大小为50G和100G
2.将50G的磁盘分成2个主分区,大小分别为10G和20G和1个扩展分区,扩展分区下划分2个逻辑分区,大小分别为5G和15G
3.然后将4个分区都格式化为ext4文件系统,新建挂载目录,具体挂载如下
10G----》/mail
20G----》/software
5G----》/movie
15G---》/photo
4.将100G的磁盘的分区表采用GPT方式,新建2个分区大小分别为40G和60G
5.然后格式化为ext4文件系统,新建挂载目录,具体挂载如下:
40G ----》/ftp
60G ---》/www
=====
[root@teacher ftp]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@teacher ftp]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
PREFIX=16
DNS1=8.8.8.8
TYPE=Ethernet
HWADDR=00:30:67:f2:10:cf
USERCTL=no
IPV6INIT=no
IPADDR=10.0.2.253
NETMASK=255.255.0.0
[root@teacher ftp]#
===
(parted) mkpart movie 20001 60000
Warning: WARNING: the kernel failed to re-read the partition table on
/dev/sdc (Device or resource busy). As a result, it may not reflect
all of your changes until after reboot.
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 2190GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 3000MB 2999MB ext4 music
2 3001MB 10.0GB 6999MB ext4 m
3 10.0GB 20.0GB 10000MB u
4 20.0GB 60.0GB 40.0GB movie
(parted) quit
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1 /dev/sdc2
[root@lichao520 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 ext4 18G 2.9G 14G 18% /
tmpfs tmpfs 186M 260K 186M 1% /dev/shm
/dev/sda1 ext4 485M 35M 426M 8% /boot
/dev/sr0 iso9660 2.9G 2.9G 0 100% /media/RHEL_6.3 i386 Disc 1
/dev/sdc2 ext4 6.5G 143M 6.0G 3% /m
[root@lichao520 ~]# umount /m 卸载
[root@lichao520 ~]# partprobe /dev/sdc 重新读取分区表,生存设备文件
[root@lichao520 ~]# ls /dev/sdc*
/dev/sdc /dev/sdc1 /dev/sdc2 /dev/sdc3 /dev/sdc4
[root@lichao520 ~]#
===
安装系统的时候,到底分多少个分区。
/ 根据实际情况,尽可能的大些
swap 4G
/boot 500M
==
/
swap
/home
/boot
===
c--》系统
d--》软件
e--》文档
f--》娱乐
===