linux系统管理之添加并挂载新硬盘
2015-04-28 19:28
190 查看
Linux系统由于数据累计增长、前期存储规划不合理等诸多因素,出现存储不够用的情况时,这是可以添加硬盘,挂载上,让数据存储在新添加的硬盘上,具体做法如下:
1添加新硬盘到服务器,重启;
2.使用fdisk -l查看分区表信息
3.使用命令fdisk /dev/sdb 进入该磁盘进行分区:
4.使用 mkfs.ext4 命令格式化磁盘成格式化成ext4各式的文件系统。
5.系统启动时自动挂载/dev/sdb1,编辑/etc/fstab文件,指定挂载目录为/mydata
到此为止,我们就可以用新添加的硬盘来存新数据了。这样的应用主要是数据库增大,一块盘不够用了,添加新盘来存后来的数据。
本人是在虚拟机上通过测试的。
1添加新硬盘到服务器,重启;
2.使用fdisk -l查看分区表信息
[root@DB-ONE-SERVER~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table Disk /dev/dm-0: 32.3 GB, 32346472448 bytes 255 heads, 63 sectors/track, 3932 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/dm-0 doesn't contain a valid partition table Disk /dev/dm-1: 10.4 GB, 10468982784 bytes 255 heads, 63 sectors/track, 1272 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/dm-1 doesn't contain a valid partition table
3.使用命令fdisk /dev/sdb 进入该磁盘进行分区:
[root@DB-ONE-SERVER~]# 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 2610. 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): p Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes 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 First cylinder (1-2610, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): Using default value 2610 Command (m for help): p Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 2610 20964793+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re- 4000 read partition table. Syncing disks. [root@DB-ONE-SERVER~]# fdisk -l /dev/sdb Disk /dev/sdb: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 2610 20964793+ 83 Linux
4.使用 mkfs.ext4 命令格式化磁盘成格式化成ext4各式的文件系统。
[root@DB-ONE-SERVER~]# mkfs.ext4 /dev/sdb1 mke4fs 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 1310720 inodes, 5241198 blocks 262059 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 160 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 Writing inode tables: done Creating journal (32768 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 tune4fs -c or -i to override.
5.系统启动时自动挂载/dev/sdb1,编辑/etc/fstab文件,指定挂载目录为/mydata
[root@DB-ONE-SERVER~]# cd / [root@DB-ONE-SERVER/]# mkdir mydata [root@DB-ONE-SERVER/]# mount -a [root@DB-ONE-SERVER/]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-sda3 30G 2.4G 26G 9% / /dev/sda1 99M 23M 71M 25% /boot tmpfs 4.0G 0 4.0G 0% /dev/shm /dev/sdb1 20G 172M 19G 1% /mydata [root@DB-ONE-SERVER/]#
到此为止,我们就可以用新添加的硬盘来存新数据了。这样的应用主要是数据库增大,一块盘不够用了,添加新盘来存后来的数据。
本人是在虚拟机上通过测试的。
相关文章推荐
- linux----软件包管理、任务计划的安排、添加硬盘、划分磁盘配额、挂载外部设备等
- Linux系统学习第三章:磁盘与文件系统管理(三)硬盘分区、格式化、检验与挂载
- Linux系统中添加硬盘,并挂载到已有的目录,比如/home/user
- Linux下添加新硬盘,分区及挂载
- Linux命令-添加新硬盘,分区及挂载[转]
- linux系统添加硬盘
- CentOS5.5 添加一块新硬盘,分区并设置系统启动自动挂载的方法
- Linux系统下挂载exFAT和NTFS格式硬盘的驱动安装和配置
- 【转】Linux下添加新硬盘,分区及挂载
- Linux下添加新硬盘,分区及挂载
- Linux添加新硬盘、分区、格式化、自动挂载
- 重新挂载linux分区&添加硬盘
- Linux添加新硬盘自动挂载硬盘
- 添加硬盘和挂载硬盘
- vmware添加新硬盘 挂载新硬盘 硬盘扩容
- Linux下添加新硬盘,分区及挂载
- Linux下添加新硬盘,分区及挂载
- linux系统下添加新硬盘的方法详解
- CentOS添加一个新的硬盘分区到挂载的过程
- linux运维:Linux下添加新硬盘+分区及挂载详细步骤图解