Linux 磁盘分区、格式化、挂载
1、添加磁盘,查看磁盘状态
[root@zhongxin172 lib]# fdisk -l WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sdb: 6001.1 GB, 6001095958528 bytes255 heads, 63 sectors/track, 729591 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000 Device Boot Start End Blocks Id System/dev/sdb1 1 267350 2147483647+ ee GPT Disk /dev/sda: 146.8 GB, 146778685440 bytes255 heads, 63 sectors/track, 17844 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008f797 Device Boot Start End Blocks Id System/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 64 1109 8388608 82 Linux swap / Solaris/dev/sda3 1109 17845 134436864 83 Linux2、用fdisk 对磁盘进行分区/查看
[root@localhost ~]# fdisk /dev/sda //这里不带数字 The number of cylinders for this disk isset to 2610.There is nothing wrong with that, but thisis larger than 1024,and could in certain setups cause problemswith:1) software that runs at boot time (e.g.,old versions of LILO)2) booting and partitioning software fromother OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): mCommand action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibilityflag d delete a partition //删除磁盘分区 l list known partition types m print this menu //查看磁盘分区功能 n add a new partition //增加一个磁盘分区 o create a new empty DOSpartition table p print the partition table //查看磁盘分区 q quit without saving changes s create a new empty Sundisklabel 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 (expertsonly) Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-652, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):Using default value 652Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.3、cat /proc/partitions查看分区情况
(如果创建完之后,/proc/partitions 查看不到对应的分区,使用parprobe /dev/sdb刷新下)
[root@zhongxin172 lib]# cat /proc/partitions major minor #blocks name 8 16 5860445272 sdb 8 17 5860445238 sdb1 8 0 143338560 sda 8 1 512000 sda1 8 2 8388608 sda2 8 3 134436864 sda34、格式化 /dev/sdb1分区
[root@db1 /]# mkfs -t ext3 /dev/sdb1mke2fs 1.35 (28-Feb-2004)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)655360 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736Writing inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 30 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.5、创建目录,并将目录挂载在/dev/sdb1下
[root@db1 /]# mkdir /u01[root@db1 /]# lsbackup dev initrd media opt sbin sys u01bin etc lib misc proc selinux tftpboot usrboot home lost+found mnt root srv tmp var[root@db1 /]# mount /dev/sdb1 /u016、验证挂载是否成功
[root@db1 /]# df -kFilesystem 1K-blocks Used Available Use% Mounted on/dev/sda1 9131772 7066884 1601012 82% /none 454256 0 454256 0% /dev/shm/dev/sdb1 5154852 43040 4849956 1% /backup7.查看磁盘 的文件系统类型
[root@zhongxin172 mysql]# parted /dev/sdb1 printModel: Unknown (unknown)Disk /dev/sdb1: 6001GBSector size (logical/physical): 512B/512BPartition Table: loop Number Start End Size File system Flags 1 0.00B 6001GB 6001GB ext48、设置开启自动挂载 (如果没有设置,重启后就丢失挂载信息)
[root@db1 /]# vi /etc/fstab# This file is edited by fstab-sync - see 'man fstab-sync' for detailsLABEL=/ / ext3 defaults 1 1none /dev/pts devpts gid=5,mode=620 0 0none /dev/shm tmpfs defaults 0 0none /proc proc defaults 0 0none /sys sysfs defaults 0 0LABEL=SWAP-sda2 swap swap defaults 0 0/dev/sdb1 /u01 ext3 defaults 0 0/dev/hdc /media/cdrom auto pamconsole,exec,noauto,managed 0 0/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0

浙公网安备 33010602011771号