LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2016, 04:22 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
CentOs7: Adding swap partition


I am trying to add a swap partition when learning CentOs7.

Quote:
[user1@localhost ~]$ sudo mkswap /dev/sda7
[sudo] password for user1:
/dev/sda7: Device or resource busy

[user1@localhost ~]$ sudo fdisk /dev/sda
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.


Command (m for help): p

Disk /dev/sda: 12.9 GB, 12884901888 bytes, 25165824 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
Disk identifier: 0x000c55ab

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 22429695 10701824 8e Linux LVM
/dev/sda3 22429696 23453695 512000 5 Extended
/dev/sda5 22431744 22534143 51200 83 Linux
/dev/sda6 22536192 22689791 76800 83 Linux
/dev/sda7 22691840 23306239 307200 83 Linux
Previously, I have change /dev/sda7 with id = 82 so that it is a Linux Swap as in:
Quote:
Device Boot Start End Blocks Id System
/dev/sda7 22691840 23306239 307200 82 Linux Swap
I still get this message:

/dev/sda7: Device or resource busy

Why is /dev/sda7 busy when it is not being in use?
What did I missed?

Last edited by fanoflq; 05-24-2016 at 04:24 PM.
 
Old 05-24-2016, 04:27 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Is it still mounted? Is it part of an LVM volume?

Code:
lvs
pvs
df -h
 
1 members found this post helpful.
Old 05-24-2016, 05:48 PM   #3
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
[user1@localhost ~]$ sudo lvs
[sudo] password for user1:
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 9.00g
swap centos -wi-ao---- 1.20g
lv00 vg00 -wi-a----- 92.00m


[user1@localhost ~]$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 10.20g 4.00m
/dev/sda5 vg00 lvm2 a-- 48.00m 48.00m
/dev/sda6 vg00 lvm2 a-- 72.00m 72.00m
/dev/sda7 vg00 lvm2 a-- 96.00m 4.00m


[user1@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 9.0G 4.1G 5.0G 46% /
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4G 152K 1.4G 1% /dev/shm
tmpfs 1.4G 8.8M 1.4G 1% /run
tmpfs 1.4G 0 1.4G 0% /sys/fs/cgroup
/dev/sda1 497M 157M 341M 32% /boot
tmpfs 285M 16K 285M 1% /run/user/1000
/dev/sr0 58M 58M 0 100% /run/media/user1/VBOXADDITIONS_5.0.16_105871



Here is my fstab:
Quote:
[user1@localhost ~]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Apr 15 14:13:23 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=d3d5cb23-fcdf-4bb5-8336-83f1c6fea777 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0

# mounting cryptsetup block device via device mapper to mount point ~/mntsda6
# /dev/mapper/sda6_mapper /home/user1/mntsda6 ext4 defaults 0 0

# no space between options flags, otherwise it is error
#/dev/sda5 /mnt/tempdir ext4 defaults,noexec 0 0
I did use extended partitions to learn about LVM in the past.
But it is not mounted as shown in /etc/fstab.
In addition, the id listed in fdisj -l for those
logical partitions are not 8e. So why is it labelled as an LVM partition as shown above?

" /dev/sda7 vg00 lvm2 a-- 96.00m 4.00m "

How do I disable the LVM on those extended logical partition?


Addendum:
From command: fdisk -l
Quote:
... ...
Disk /dev/mapper/vg00-lv00: 96 MB, 96468992 bytes, 188416 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
... ...
and

Quote:
[user1@localhost mapper]$ pwd
/dev/mapper
[user1@localhost mapper]$ ls -al
total 0
.... ...
lrwxrwxrwx. 1 root root 7 May 24 18:41 vg00-lv00 -> ../dm-2
[user1@localhost mapper]$ file vg00-lv00
vg00-lv00: symbolic link to `../dm-2'

Last edited by fanoflq; 05-24-2016 at 06:06 PM.
 
Old 05-24-2016, 07:21 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
Just for grins, be sure swap isn't mounted already.

Typical Centos installs tend to use LVM and then use linux filesystem within that LVM.

Just a note.
I realize you are trying to learn but in this case you may wish to consider adding a swap file instead.

Last edited by jefro; 05-24-2016 at 07:24 PM.
 
Old 05-24-2016, 07:56 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
sda7 is not mounted but it is still part of the VG/LV. linux does not use partition IDs so it does not matter if it is labeled as 83 or a 8e.

To remove sda7 ...
lvremove lv00 (removes logical volume)
vgremove vg00 (removes volume group)
pvremove /dev/sda7 (removes sda7 as a PV)

Should be able to format and enable swap on sda7 independently of the existing swap i.e. /dev/mapper/centos-swap
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CentOS7 won't boot after motherboard swap. UEFI? dracut-initqueue timeouts... gargunkle Linux - Software 1 03-18-2016 08:14 PM
Would a Linux swap partition work as a FreeBSD swap partition? Froggy192 *BSD 11 07-27-2013 02:06 PM
Adding SWAP Partition ej_219 Linux - General 11 06-27-2013 03:01 PM
Adding a swap partition after the fact? Mark Anderson Ubuntu 6 04-03-2007 04:06 PM
Adding Swap Partition Post-Install slickhare Linux - Newbie 2 11-28-2006 08:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration