Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have an Acer Aspire R laptop with 260GB SSD, UEFI, Ubuntu and Windows 10 dual boot. How can I backup / clone / image the whole drive to be reinstalled on a new drive if current drive fails?
Clonezillla: Will it backup all partitions (EFI, recovery, Ubuntu, swap, Windows) to external drive, so I can restore it to a new drive, no problem? Which file system should the external drive have?
GParted: Or should I partition the external drive like the existing drive and copy the partitions with gparted?
You can use Clonezilla to make a bootable copy of the whole existing SSD with all of its partitions including Windows.
The boot menu comes from Grub2 and it gets created from templates in /etc/grub.d and settings from /etc/default/grub.
So, if your Clonezilla ISO file lives at /srv/iso/clonezilla-live-disco-amd64.iso and /srv directory lives in hard drive 0 in partition 13, then create a new executable file in /etc/grub.d, such as 40_clonezilla and put the following in it:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Clonezilla live" {
set root=(hd0,13)
set isofile="/iso/clonezilla-live-disco-amd64.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts= ocs_live_batch=\"no\" locales= vga=788 ip=frommedia nosplash toram=live,syslinux,EFI findiso=$isofile
initrd (loop)/live/initrd.img
}
Then, run update-grub to regenerate your grub menu.
When you reboot, you will have a new boot option that boots from Clonezilla, and, from there, you can make a bootable copy of the existing hard-drive onto an external drive and overwrite whatever is already on that external drive.
All of this stuff, editing Grub templates and overwriting drives is quite dangerous and the penalty for getting something wrong is high.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Wanted to reduce a filesystem space.
Did a lvreduce on it. lvreduce successfully ran.
sudo lvreduce -L 40G /dev/mapper/tmp
when i am trying to do mkfs.xfs force it is not allowing me saying
mkfs.xfs: /dev/tmp contains a mounted filesystem
sudo lvmdiskscan shows the correct space after lvreduce. But when i mount it back it is not showing correct space
Can anyone please help here ? Let me know if you need more details
Thanks in advance
I was having a similar issue and I found this:
https://discuss.pivotal.io/hc/en-us/articles/201816273-xfs-repair-failed-with-error-message-dev-sdb-contains-a-mounted-filesystem-
Basically, comment out the mount in your fstab and then reboot. Then perform your format or repair. Re-mount as needed, either manually or in your fstab.
This worked for me.
I was having the same problem. The way I solved it was
In the console enter tu super user su -l
fdisk -l to list the devices table
fdisk /dev/device-name
p to print the partition table of the device
d to delete partitions
n to create a new partition
if you don't know how to use it you can press m to launch help
t to assign the tipe of partition, I usually use linux ext4
w to write the new partition table in the device
Is very important to press w
Then you can use mkfs
mkfs.fat -F32 /dev/sbc1 you have to change sdc1 with the partition you want to format the -F32 is used in order to assign fat32 file system.
2.exit to standar user
First unmount with umount device then perform the size reduction
Unmount the selected partition in Disk Utility with the stop icon button.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I would like to know how to copy a Linux partition (example: /dev/sda1) on a USB stick, and then boot on the USB stick.
I tried to just copy it with the command cp but when I tried to boot on it, it booted on the partition I copied (/dev/sda1) and not the usb.
In short what I want to do is create a USB stick with my Linux partition on it that I can boot on with any computer.
Thank you.
cp is great for copying files, but you should consider it too high-level for copying partitions. When you copy a partition, you read from a device file and write to another device file, or normal file, or what ever. With cp, many file attributes might be changed: modification time, owner, permissions, etc. This isn't great for partition copies, e.g. files owned by root should still be owned by root, or ~/.ssh/config should still have permissions 600.
The program for this task is dd, which copies bit-by-bit. You specify an input file and an output file:
dd if=/dev/sda of=/dev/sdf bs=512
This copies contents of /dev/sda to /dev/sdf while reading 512 bytes at a time (bs=blocksize). After some time, it will finish and report some statstics. To get statistics during copying, you must send SIGUSR1 signal to the dd process.
Please beware that dd is a dangerous tool, if incorrectly used: For example, it won't ask you for permission to overwrite your 10000 picture vacation album. It simply does. Make sure to specify the correct device files!
You also have to take care that sizes of source and destination fit: destination needs to be at least the size as the source. If you have a 500GB hard disk it won't work to copy to a 4GB USB stick.
Copying whole hard disks also copies the boot loader. An issue with this might be, that the entries in boot loader configuration reference wrong disks. However, starting the boot loader should be no problem (provided architecture matches). If you use GRUB, you even get a command line, which you can use to boot the system manually.
Please change your bios setting so that the first boot device is USB.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Being a super user , I executed the following command on linux
rm rm
which removes itself. Because when process is in execution , its reference count
is not zero.Hence it cannot be deleted. So I am bemused,
how and why does it happen?
I tried the same with chown 0000 chown as well.
cp -r Dir1/ Dir2/
In above command also , what happens when i delete the source directory only when copying is in progress???
It is the same as for temporary files.
Recall that a usual way to create some temporary file is to open(2) a file (keeping its file descriptor), then unlink(2) (while still having an open file descriptor). Then the data of the file remains in the file system as long as the process is running and have not close(2)-d that file descriptor.
This is because files really are inodes -not file names in directories. (directories contain entries associating names to inodes).
The kernel manages the set of "used" (or "opened") inodes, and that set contains the inodes executed by processes (actually, the inodes involved in some address mapping like thru mmap(2) or execve(2))
So just after /bin/rm /bin/rm starts, the kernel has one reference to rm binary as the executable of the process.
When it processes the unlink syscall, it has temporarily two references (one being the process in execution, the other the path /bin/rm passed to unlink kernel implementation) and decreases it to one.
Of course you should avoid typing /bin/rm /bin/rm but then you usually have some standalone shell like sash to be able to repair your system.
On Windows, "rm rm" is probably not possible, because of the reference count you mentioned. On most *nix systems however, it is. "rm" and also "chmod" is loaded into memory and only then will execute whatever the commandline specified. Another example: edit a file in one window and while editing that file, remove it in another window. That too should be possible on most *nix systems, regardless of reference counts.
You cant delete a directory using rm until its empty..
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have read about limiting size of directory - like creating big files, formatting,mount,.. etc.
But this all very complicated. Does exist utility or something else to set limit on already existing directory?
Quota is based upon filesystems, but you can always create a virtual filesystem and mount it on a specific (empty) directory with the usrquota and/or grpquota flags.
In steps this will be:
create the mount point
create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual filesystem
format this file with an ext3 filesystem (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
mount the newly formatted disk space in the directory you've created as mount point, e.g.
Code:
mount -o loop,rw,usrquota,grpquota /path/to/the/formatted/disk/space /path/of/mount/point
Set proper permissions
Set quotas
and the trick is done.
Tutorial here.
Original answer here
You could limit the quota on a filesystem. But it is not directory specific, but file system & user specific.
You might also consider developping your own user space file system using FUSE, but this will take your time.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Let's assume I have a hard drive with some linux distribution on it. My task is to set up similar system (with similar distro, kernel version, software versions etc.) on the other hard drive. How can i do that if:
Case a: I'm allowed to use any software i want (include software like Virtualbox to make full image of the system)
Case b: I'm not allowed to use anything but standard linux utilities to retrieve all characteristics i need, and then install "fresh" system on other hard drive manually.
Thanks for reading. It's very hard to me to express what i mean, i hope you understood it.
One word: CloneZilla
It can clone the partitions, disks, copies the boot record. You can boot it up from CD or USB drive or even via network (PXE).
You could go with dd but it's slow because it copies everything, even the empty space on disk, and if your partitions are not the same size you can have various problems, so I do not recommend dd.
You could also boot the system from some live CD like Knoppix, mount the partitios and copy everything using cp -a. And run something like watch df in a second terminal to monitor the progress. But even then you need to mess with the bootloader after copy is done.
I used to use various manual ways to clone Linux systems in the past, until I discovered CloneZilla. Life is much easier since then.
Easiest way is to use dd from the command prompt.
dd if=/dev/sda of=/dev/sdb --bsize=8096
dd (the disk duplicator) is used for exactly this purpose. I would check the man page to ensure my blocksize argument is correct though. The other two arguments are if (in file) and of (out file). The of= hard drive should be the same size or larger than the if= hard drive.
You can create an exact copy of the system on the first disk with dd or cpio and a live cd.