disks on vmware (/dev/sda) was extended (it is RHEL5, can't use lvm) from 20G to 40G .. if I use fdisk /dev/sda I can create /dev/sda7, but this partition have just 2G, why the partition have just 2G and how I fix it ? thanks
I tried:
fdisk /dev/sda and create /dev/sda7
df -Th
...
/dev/sda2 ext3 6.8G 6.0G 478M 93% /
/dev/sda7 ext3 2.0G 36M 1.9G 2% /home
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 131 1052226 83 Linux
/dev/sda2 132 1045 7341705 83 Linux
/dev/sda3 1046 1567 4192965 82 Linux swap / Solaris
/dev/sda4 1568 2610 8377897+ 5 Extended
/dev/sda5 1568 2089 4192933+ 83 Linux
/dev/sda6 2090 2350 2096451 83 Linux
/dev/sda7 2351 2610 2088418+ 83 Linux
used also parted:
Number Start End Size Type File system Flags
1 32.3kB 1078MB 1077MB primary ext3 boot
2 1078MB 8595MB 7518MB primary ext3
3 8595MB 12.9GB 4294MB primary linux-swap
4 12.9GB 21.5GB 8579MB extended
5 12.9GB 17.2GB 4294MB logical ext3
6 17.2GB 19.3GB 2147MB logical ext3
19.3GB 21.5GB 2139MB Free Space
21.5GB 42.9GB 21.5GB Free Space
Warning: You requested a partition from 21.5GB to 42.9GB.
The closest location we can manage is 21.5GB to 21.5GB. Is this still acceptable to you?
Yes/No? no
(parted) mkpart
Partition type? [logical]?
File system type? [ext2]? ext3
Start? 22G
End? 40G
Warning: You requested a partition from 22.0GB to 40.0GB.
The closest location we can manage is 21.5GB to 21.5GB. Is this still acceptable to you?
Yes/No? no
(parted)
problem is I can't resize more than 2G
type:
parted /dev/sd?
(parted) print free
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 1075MB 1074MB primary ext3
2 1075MB 2149MB 1074MB primary ext3
3 2149MB 3222MB 1074MB primary ext3
4 3222MB 7443MB 4221MB extended
5 3223MB 4297MB 1074MB logical ext3
6 4298MB 5372MB 1074MB logical ext3
7 5373MB 5897MB 524MB logical ext3
5897MB 7443MB 1546MB Free Space
7443MB 8590MB 1147MB Free Space
(parted) resizepart 4
End? [7443MB]? 8590MB
(parted) print free
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 1075MB 1074MB primary ext3
2 1075MB 2149MB 1074MB primary ext3
3 2149MB 3222MB 1074MB primary ext3
4 3222MB 8590MB 5368MB extended
5 3223MB 4297MB 1074MB logical ext3
6 4298MB 5372MB 1074MB logical ext3
7 5373MB 5897MB 524MB logical ext3
5897MB 8590MB 2693MB Free Space
(parted) quit
now I resized extended partition
Related
here is example from our rhel server machine
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 20G 0 disk /data/sdb
sdc 8:32 0 20G 0 disk /data/sdc
sdd 8:48 0 20G 0 disk /data/sdd
sde 8:64 0 20G 0 disk /data/sde
sdf 8:80 0 42G 0 disk
sdg 8:96 0 42G 0 disk
sdh 8:112 0 42G 0 disk
we want to Create a Disk Partitions for the other disks as sdf,sdg,sdh , but all this process should be by bash script and we want to automate the process
first here is example how to create 2 partitions for sdf disk ,
so in this example we create two partitions each one will get 10G size
step 1 ( create partitions when each partition take 10G )
parted /dev/sdf
GNU Parted 3.1
Using /dev/sdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos <-- sending text (1)
(parted) mkpart primary 0 10024MB <-- sending text (2)
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I <-- sending text (3)
(parted) mkpart primary 10024MB 20048MB <-- sending text (4)
(parted) quit <-- sending text (5)
Information: You may need to update /etc/fstab.
and now we get ( the expected results )
lsblk
sdf 8:80 0 42G 0 disk
├─sdf1 8:81 0 9.3G 0 part
└─sdf2 8:82 0 9.3G 0 part
can we automate the parted process ? or maybe by other approach ( for example by fdisk ) ?
in order to use this automated process in python3/bash script
Note - we not have expect on our Linux machines
reference - https://www.tecmint.com/create-disk-partitions-in-linux/
The parted option --script is what you are looking for.
Create a text file with the parted commands you want to execute (simulate interactive) and use the above option on the command line in the following manner:
parted --script ${batch_file}
I would do that for only one partition at at time until the batch_file content is verified to be correct and reliable.
One observation: you may want to modify
mkpart primary 0 10024MB
to show
mkpart primary 0 10080MB
to eliminate the mis-alignment being reported (disk access performance hit from mis-alignment).
The approach is to calculate a number that is a multiple of 512 bytes, but divisible by 2048 or 4096 depending on what the disk reports is the physical sector size. For example:
4096 * 1024 * (2048 + 256 + 128 + 64 + 32 - 16 + 8) = 1279918080
1279918080 / (1024 * 1024) = 10080 GB
I have an oVirt installation with CentOS Linux release 7.3.1611.
I want to add a new drive (sdb) to the oVirt volume group to work with VMs.
Here is the result of fdisk on the drive:
[root#host1 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be
careful before using the write command.
Orden (m para obtener ayuda): p
Disk /dev/sdb: 300.1 GB, 300069052416 bytes, 586072368 sectors
Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512
bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk
label type: dos Identificador del disco: 0x7a33815f
Disposit. Inicio Comienzo Fin Bloques Id Sistema
/dev/sdb1 2048 586072367 293035160 8e Linux LVM
The partitions are showed up in /proc/partitions:
[root#host1 ~]# cat /proc/partitions
major minor #blocks name
8 0 293036184 sda
8 1 1024 sda1
8 2 1048576 sda2
8 3 53481472 sda3
8 4 1 sda4
8 5 23072768 sda5
8 6 215429120 sda6
8 16 293036184 sdb
8 17 293035160 sdb1
When I execute the command to create PV with "pvcreate /dev/sdb1" the result is:
[root#host1 ~]# pvcreate /dev/sdb1
Device /dev/sdb1 not found (or ignored by filtering).
I have revised the file /etc/lvm/lvm.conf for the filters, but I do not have any filter that makes LVM discarding the drive. I have rebooted the computer after creating the PV with pvcreate. I did research on Google for the error but no idea.
Thanks. Any help would be appreciated Manuel
Try to edit lvm.conf uncomment global_flter and edit like this
global_filter = [ "a|/dev/sdb|"]
After that edit multipath vi /etc/multipath.conf
[root#ovirtnode2 ~]#lsblk /dev/sdb NAME
MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb
8:16 0 200G 0 disk └─3678da6e715b018f01f1abdb887594aae 253:2
0 200G 0 mpath
edit
vi /etc/multipath.conf
append the following to multipath.conf blacklist {
wwid 3678da6e715b018f01f1abdb887594aae }
service multipathd restart
its work for me, and i have that problem to when im trying on ovirt but
[root#ovirtnode2 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb"
successfully created. [root#ovirtnode2 ~]#
I only have one disk and it has lots free space unused with only one primary partition. I want to create a .img image as a backup without free space.
i do some search on 'create img image'(without free space), most anwser give:
dd if=/dev/sdb | gzip > backup.img.gz
Now I have two question:
I only have one disk(sda) with all space in one partition(sda1), is it possible to create a .img image with the dd order without adding another disk? If 'yes', then what should i do? Running dd if=/dev/sda | gzip > backup.img.gz at /home/xxx will be ok? will dd copy the .img file itself to the iamge?
It's better to get a .img file, not a .img.gz file, without free space. is that possible in my condition(one disk)?
here's the condition of my computer(sorry for the system language):
root#act-Precision-T1500:/home/act# df
df: "/mnt/udisk": 输入/输出错误
文件系统 1K-块 已用 可用 已用% 挂载点
udev 1983824 4 1983820 1% /dev
tmpfs 400464 1252 399212 1% /run
/dev/sda1 476502040 64401980 387872068 15% /
none 4 0 4 0% /sys/fs/cgroup
none 5120 0 5120 0% /run/lock
none 2002320 180 2002140 1% /run/shm
none 102400 40 102360 1% /run/user
root#act-Precision-T1500:/home/act# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d1403
设备 启动 起点 终点 块数 Id 系统
/dev/sda1 * 2048 968466431 484232192 83 Linux
/dev/sda2 968468478 976771071 4151297 5 扩展
/dev/sda5 968468480 976771071 4151296 82 Linux 交换 / Solaris
Do i express myself clearly? I'm a beginner to Linux and my English is awful. Thank you for helping me!
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 3999.7 GB, 3999688294400 bytes
255 heads, 63 sectors/track, 486267 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 1 267350 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
/dev/sda2 1 2090 16785120 82 Linux swap / Solaris
/dev/sda3 1 218918 1758456029+ 8e Linux LVM
Partition table entries are not in disk order
Above is my "fdisk -l", my current problem is when I go and try to do "pvcreate /dev/sda2" it gives me "Can't open /dev/sda2 exclusively. Mounted filesystem?" and I have been searching google for a while now trying to find a way to fix this. There is defiantly things I tried from google but none of them ended up working.
You're trying to initialize a partition for use by LVM that's currently used by swap.
You should rather run
pvcreate /dev/sda3
i updated to the new Kernel and the problem was resolved in RHEL 6 . Had upgraded from 2.6.32-131.x to 2.6.32-431.x
Check those disks/partition you are using, are not mounted to any directory on your system.
If yes, umount them and try again.
I used the command df-h on my centos 6.1
here's the output
[root#localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
50G 2.3G 45G 5% /
tmpfs 5.9G 0 5.9G 0% /dev/shm
/dev/sda1 485M 35M 425M 8% /boot
/dev/mapper/VolGroup-lv_home
2.0T 199M 1.9T 1% /home
i found out that the hard disk is two terabyte. but when I used the command cat /proc/partitions | more
here's the output
[root#localhost sysconfig]# cat /proc/partitions | more
major minor #blocks name
8 0 4293656576 sda
8 1 512000 sda1
8 2 2146970624 sda2
253 0 52428800 dm-0
253 1 14417920 dm-1
253 2 2080120832 dm-2
you could see on the first line. it is 4396.7 GB . why is it i could only see is 2TB? how could i find my missing another 2TB and make it a partition.
I also use the command lsblk
here is the output
[root#localhost ~]# lblsk
-bash: lblsk: command not found
[root#localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO MOUNTPOINT
sda 8:0 0 4T 0
ââsda1 8:1 0 500M 0 /boot
ââsda2 8:2 0 2T 0
ââVolGroup-lv_root (dm-0) 253:0 0 50G 0 /
ââVolGroup-lv_swap (dm-1) 253:1 0 13.8G 0 [SWAP]
ââVolGroup-lv_home (dm-2) 253:2 0 2T 0 /home
sr0 11:0 1 1024M 0
using the parted /dev/sda i type the print free command
here's the output
(parted) print free
Model: DELL PERC 6/i (scsi)
Disk /dev/sda: 4397GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 2199GB 2198GB primary lvm
2199GB 4397GB 2198GB Free Space
I was wrong, sorry. As you can see in parted print free output you have 2 MBR partitions - boot and lvm and 2198GB free space (last row).
If you want to use all of your space you have to use GPT partitions. These partitions as opposed to MBR partition that can only address up to 2TB, can address your whole disk and up to 8 ZiB (zebibytes).
You can try to convert MBR partition table to GPT (example 1, example 2), though I strongly recommend to backup your data.
You are using tools showing info from different layers of your system and interpreting it wrong.
df, according to man page, will display the space available on all currently mounted file systems.
/proc/partitions holds info about partitions on your drive - physical device. This file shows you size of your drive as number of blocks. Usually, on HDD block size is a size of sector - 512 bytes.
So, sda size of 4293656576 is size in blocks, not kilobytes.
4293656576 blocks = (4293656576 / 2 ) kilobytes = 2146828288 KiB = 2047.375 GiB, or 2198.352 GB.
Assuming 1 GiB = 1 * 2^30, 1 GB = 1 * 10^3.
If you want to see size of your disk use fdisk -l <device name>.