利用fdisk将硬盘剩余空间进行分区

1.首先查看分区,发现300多G的硬盘/dev/sdc1只使用了200多G而已

[[email protected] dbbackup]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda2              16G  9.6G  5.1G  66% /

/dev/sda1              99M   19M   76M  20% /boot

tmpfs                1006M   22M  984M   3% /dev/shm

/dev/sdb1              79G   39G   37G  52% /disk1

/dev/sdc1             197G  173G   15G  93% /disk2

[[email protected] dbbackup]# fdisk -l

Disk /dev/sda: 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/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        2088    16667437+  83  Linux

/dev/sda3            2089        2610     4192965   82  Linux swap / Solaris

Disk /dev/sdb: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       10443    83883366   83  Linux

Disk /dev/sdc: 322.1 GB, 322122547200 bytes

255 heads, 63 sectors/track, 39162 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1       26108   209712478+  83  Linux

2.进行分区

[[email protected] dbbackup]# fdisk /dev/sdc

The number of cylinders for this disk is set to 39162.

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): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (26109-39162, default 26109): 回车(仔细看就会发现这个是sdc1结束扇区+1的值

Using default value 26109

Last cylinder or +size or +sizeM or +sizeK (26109-39162, default 39162): 回车

Using default value 39162

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.

[[email protected] dbbackup]# partprobe

[[email protected] dbbackup]# fdisk -l

Disk /dev/sda: 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/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        2088    16667437+  83  Linux

/dev/sda3            2089        2610     4192965   82  Linux swap / Solaris

Disk /dev/sdb: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       10443    83883366   83  Linux

Disk /dev/sdc: 322.1 GB, 322122547200 bytes

255 heads, 63 sectors/track, 39162 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1       26108   209712478+  83  Linux

/dev/sdc2           26109       39162   104856255   83  Linux

[[email protected] dbbackup]# mkfs.ext3 /dev/sdc2 

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

13107200 inodes, 26214063 blocks

1310703 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

800 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 38 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[[email protected] dbbackup]# mkdir /disk3

[[email protected] dbbackup]# mount /dev/sdc2 /disk3

添加到/etc/fstab

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

LABEL=SWAP-sda3         swap                    swap    defaults        0 0

/dev/sdb1               /disk1                  ext3    defaults        1 3

/dev/sdc1               /disk2                  ext3    defaults        1 4

/dev/sdc2               /disk3                  ext3    defaults        1 5

时间: 2024-08-01 02:00:51

利用fdisk将硬盘剩余空间进行分区的相关文章

fdisk硬盘分区(1)——系统盘剩余空间创建分区

想必大家都应该会windows下创建新分区吧(如果不熟悉的话,下面的就不用浪费时间看了) 简单回顾分区的关键步骤 1.指定分区大小 2.分区格式化 3.指定访问入口 为啥分区要经过这几个步骤呢?我们可以用制作练习本的流程 1.我们采购一批白纸回来肯定是很大张的,所以第一步要裁剪到练习本的大小--这一步类似指定分区大小 2.然后要在纸上印上横线或者格子,方便人们写字的时候对其--这一步类似格式化 3.最后要把练习本装订成册--这一步类似指定访问入口 所以在centos上分区也要经过以上几个步骤,但

实时监控本机内存和硬盘剩余空间,剩余内存小于 500M、根分区剩余空间小于 1000M 时,发送报警

#!/bin/bashgen_size=$(df / |awk '/\//{print $4}') #提取根分区剩余空间mem_size=$(free |awk '/Mem/{print $4}') #提取内存剩余空间while :do#注意内存和磁盘提取的空间大小都是以 Kb 为单位if [ $gen_size -le 512000 -a $mem_size -le 1024000 ];thenmail -s Warning root <<EOFInsufficient resources,

C# 获取电脑硬盘剩余空间

获取本地硬盘的所有剩余空间: 主要应用到System.IO类库的:Driveinfo.Directory,将model转换成json需要用到Newtonsoft.Json.JsonConvert.SerializeObject方法 主要方法: public DiskList DisklistCon(string disk) { DiskList dl = new DiskList(); string[] diskcon = null; dl.msgList = new List<DiskCon>

linux下硬盘的安装及分区fdisk

摘要:本文将通过虚拟机VMware模拟增加新硬盘来介绍linux下对新增硬盘的分区及安装.在本文中,将通过虚拟机增加一个10G的SCSI接口的虚拟硬盘,然后对这块新的虚拟硬盘建立3个分区,在第1个和第3个分区上建立ext3fs文件系统,把第2个分区留作swap交换分区.首先,将硬盘安装至电脑主机上面,这里指的是硬件的安装.本文采用的是通过虚拟机增加一块10G的虚拟的SCSI硬盘.虚拟机下如何增加一块硬盘,可参考如下网址:https://jingyan.baidu.com/article/0eb4

Linux LVM硬盘管理及LVM分区扩容

LVM磁盘管理 一.LVM简介... 1 二. LVM基本术语... 2 三. 安装LVM... 3 四. 创建和管理LVM... 4 2. 创建PV.. 6 3. 创建VG.. 7 4. 创建LV.. 9 5.LV格式化及挂载... 10 一.LVM简介 LVM是 Logical Volume Manager(逻辑卷管理)的简写,它由Heinz Mauelshagen在Linux 2.4内核上实现.LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可

再vm虚拟机中增加一块硬盘,并进行分区,格式化

首先增加一块硬盘,这里选择IDE接口,区别于系统原来的一块SATA接口的硬盘 启动,看看在系统中使用fdisk看添加成功没有 这里可以看到系统识别出来了,为hda,而且说没有分区表 我们来进行分区,使用命令fdisk,fdisk为一个交互式命令,我们可以用m查看帮助,常用操作用红框标出 4.新建一个主分区,2G大小 5.再建一个主分区4G大小 6.系统分区限制最多只能分配4个分区,最多3个主分区,1个扩展分区,而扩展分区可以分出多个逻辑分区出来,接下来把所有的空间给扩展分区 7.扩展分区还不能直

Linux 查看文件夹大小,磁盘剩余空间(du/df)

1. 简介 du查看目录大小,df查看磁盘使用情况. 2. du disk usage (1)基本功能 递归查看文件夹下所有文件的大小 (2)常用参数: -h, –human-readable 以可读性较好的方式显示尺寸(例如:1K 234M 2G) -s, –summarize 只分别计算命令列中每个参数所占的总用量 (3)其它参数说明: -a, –all 输出所有文件的磁盘用量,不仅仅是目录 –apparent-size 显示表面用量,而并非是磁盘用量:虽然表面用量通常会小一些,但有时它会因

如何在linux下查看目录的剩余空间大小

df命令是linux系统以磁盘分区为单位查看文件系统,可以加上参数查看磁盘剩余空间信息,命令格式: df -hl 显示格式为: 文件系统 容量 已用 可用 已用% 挂载点 Filesystem Size Used Avail Use% Mounted on /dev/hda2 45G 19G 24G 44% / /dev/hda1 494M 19M 450M 4% /boot /dev/hda6 4.9G 2.2G 2.5G 47% /home /dev/hda5 9.7G 2.9G 6.4G

Linux挂载新硬盘和创建Swap分区的方法

Liunx添加新硬盘其实和Windows的操作一样,但一个是图形化操作,另一个是命令行操作,不过步骤是一样,下面就动手演示和讲解 Linux挂载新硬盘 1.查看硬盘信息 命令:fdisk -l [[email protected] ~]# fdisk -l Disk /dev/vda: 21.5 GB, 21474836480 bytes #第一块硬盘的信息和分区信息 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of