23
votes
How to reset a Harddisk (delete Mbr & delete Partitions) from the Command Line with a script without rebooting?
The wipefs (Debian/Ubuntu package: util-linux) program lets you easily delete the partition-table signature:
wipefs -a /dev/sda
You still have to stop any process using the device though, such as LVM....
14
votes
Shrink partition to exactly fit the underlying filesystem size
Here is an example of the whole process.
This is the hard disk:
root@debian:~# fdisk /dev/loop0
Command (m for help): p
Disk /dev/loop0: 4,9 GiB, 5243928576 bytes, 10242048 sectors
Units: sectors of ...
12
votes
Accepted
Shrink partition to exactly fit the underlying filesystem size
Sizes reported by df will be incorrect as they account only for data blocks and miss blocks used internally by the filesystem as well as the reserved blocks.
The easy way is to shrink your filesystem ...
8
votes
Does LVM need a partition table?
Even if in the past I was using MS-DOS disklabel or GPT disklabel for PV, I prefer now to use directly LVM on the main block device. There is no reason to use 2 disklabels, unless you have a very ...
6
votes
extend MBR disk with ext4 partition to over 2 TB on CentOS 7
There are two major partitioning schemes in use today: MBR and GPT.
The older, deprecated, and probably still most used one is MBR. However, MBR uses 32 bit to address storage space, using 512 Byte ...
6
votes
Accepted
pvs not showing correct available space
LVM will only show space that has been formatted for LVM by using pvcreate. Here, it doesn't seem you even have a partition.
1) First you need to create the partition (sda3 I suppose), using your ...
6
votes
How to reset a Harddisk (delete Mbr & delete Partitions) from the Command Line with a script without rebooting?
I have always simply used parted for this. It works well for changing the disklabel type and adding/removing partitions, especially since it can handle modern large HDDs unlike fdisk.
You can run
$ ...
6
votes
Does LVM need a partition table?
According to LVM guide from RedHat, section 4.2.1
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/physvol_admin
They said there is ...
4
votes
How to reset a Harddisk (delete Mbr & delete Partitions) from the Command Line with a script without rebooting?
Use improved non-interactive version of fdisk, which is sfdisk
To erase partition table use this command:
sfdisk --delete /dev/sda
4
votes
Accepted
10TB HDD has a 9999GB partition but only allows me to access 215gb
You have LVM. A partition manager is limited in what it will show about logical volumes.
See what LVM looks like with a quick pvs; vgs; lvs;. Probably whomever set this up did a smart thing and did ...
4
votes
Accepted
Disk Size is not Consistent Between fdisk and parted
fsdisk shows 20 GiB, which means 20 gibibyte.
this equals to 20 * 2^30 = 21474836480 bytes
This is rounded by parted to 21.5 gigabyte (GB).
3
votes
Accepted
ZFS on Linux: Deleting the "Solaris reserved 1" partition. Did I break anything?
ZFS has tools for this.
In order to resize ZFS pools, you're supposed to use the following after rescanning the device in VMware:
zpool online -e my-pool /dev/sdb
Sometimes you need a partprobe ...
3
votes
Accepted
How to remove SWAP partition, and add back to root partition in cli
I've found that it is easier and safer to do a compressed tar backup, re-install the OS to your new configuration and then restore the files.
Also, no matter how much RAM, I still leave 4GB for swap ...
3
votes
Accepted
Why there is a difference in size reported by lsblk, gdisk and parted
Disk manufacturers advertise disk sizes in multiples of 1000. That is, a "KB" is 1000 and not 1024 as software people are used to.
For you, it seems that lsblk and gdisk are using the 1024 value but ...
2
votes
Centos 6 partition raid
You need these tools:
Install "lsscsi". It's very good to find out what drives you actually
have.
Install "disktype". If you point it on a drive you'll be able
to see what is actually there.
Use "cat ...
2
votes
pvs not showing correct available space
I got the same issue, so I type on my CLI as root pvresize /dev/sdaX. After, pvscan to confirm. Done my physical disk mounted on my linux show me all the space though its not using in the LVM.
1
vote
Accepted
Not able to get swap partition UUID after creating it with Parted ansible's module
Ok finally I found the solution.
The problem is that when the partition is not mounted, it have no UUID. When working with data partitions like xfs, extX, etc... The partition is directly mounted by ...
1
vote
Not able to get swap partition UUID after creating it with Parted ansible's module
As far as I understand the scenario and know from own experience, the behavior seems to be intended. The OS must be "forced" to re-read the partition table once changes have been done and ...
1
vote
Partition didn't resize after increasing OS Disk Size in Azure
First you will have to enlarge the existing partition to use the full disk space. I don't know if you can do it with the GUI you show. From the command line you can use fdisk. ~This seems to be old-...
1
vote
Partition didn't reflect the changes after increasing OS Disk Size in Azure
When you increase the disk size in Azure all you are doing is increasing the size of the underlying disk, you are not doing anything in OS to have it use that extra space.
Now you have a larger disk ...
1
vote
Accepted
Extending a partition on a VMware disk in Linux
fdisk isn't good at working with GPT tables. First repair the GPT table with parted:
bob@apollo:~$ sudo parted -l
Warning: Not all of the space available to /dev/sdb appears to be used, you can
...
1
vote
Accepted
Extended/Logical partition with parted
I run following to achieve it
part /boot --fstype=xfs --onpart=/dev/sda3
part pv.192 --onpart=/dev/sda5 --size 1 --grow
volgroup centos pv.192
logvol / --fstype="xfs" --name=root --...
1
vote
Extended/Logical partition with parted
Read Logical Volume Manager documentation. The partitions flagged as lvm are physical volumes, containing logical volumes.
Partitioning is not needed for most LVM using systems. Let the installer ...
1
vote
Accepted
Resize partition using parted
I guess the older version of parted was not great.
I used Gparted Live(latest parted version) on USB and booted it. That seems to make it work!
I was able to expand the partition using "resizepart".
...
1
vote
pvs not showing correct available space
I had to use growpart /dev/sda 3 (notice the space between /dev/sda and 3!) (extended the disk on Hyper-V (VHDX)).
See this great post: https://superuser.com/a/1748427/560320
1
vote
undo rm in parted - recover parition? cancel operations?
From the manual:
It is only after Parted exits that the Linux kernel knows about the
changes Parted has made to the disks. However, the changes caused by
typing your commands will probably be ...
1
vote
Accepted
Copying parition tables (only) on two GPT HDDs of 4TB each
Just want to add that the -R option of sgdisk does exactly what you are doing in the first two steps.
sgdisk -R /dev/sdb /dev/sda
sgdisk -G /dev/sdb
What do you do next? Mount the partitions and ...
1
vote
How to remove SWAP partition, and add back to root partition in cli
You can forward X11 through ssh and open gparted GUI in your client.
If your client is a Windows machine, you can use putty and xming. An example guide can be http://www.geo.mtu.edu/geoschem/docs/...
1
vote
Partitions on Linux and their CHS dependance
Wrong, it sould care in case you use Grub4DOS map onto memory, it uses C/H/S not LBA and with a lot of VHD files the MBR say C/H/S value different from the partition C/H/S value.
That when the VHD ...
1
vote
Recreate XFS Partition with Existing Filesystem
So someone overwrote the entire volume with a new, empty XFS file system, and your problem is that you need to find the superblock of the old one, because the superblock contains a random number that ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
parted × 75partition × 31
linux × 27
fdisk × 17
hard-drive × 9
lvm × 9
centos × 7
redhat × 7
centos7 × 6
gpt × 6
raid × 5
xfs × 5
debian × 4
storage × 4
virtual-machines × 3
filesystems × 3
centos6 × 3
disk-space-utilization × 3
ubuntu × 2
azure × 2
command-line-interface × 2
ansible × 2
mdadm × 2
qemu × 2
dd × 2