- Linux Hard Disk Format Command
- Step #1 : Partition the new disk using fdisk command
- Step#2 : Format the new disk using mkfs.ext3 command
- Step#3 : Mount the new disk using mount command
- Step#4 : Update /etc/fstab file
- Task: Label the partition
- How To Format USB Drive in Linux Command Line
- Step 1 – Attach USB to System
- Step 2 – Format USB Drive in Linux
- Conclusion
- Форматирование исходного кода в Linux средствами ClangFormat: проблемы и решение
- Проблемы с форматированием и как их решить
- Решение
Linux Hard Disk Format Command
Q. I’ve installed a new 250GB SATA hard disk on our office CentOS Linux server. How do I format a hard disk under Linux operating system from a shell prompt?
A. . There are total 4 steps involved for hard disk upgrade and installation procedure:
Step #1 : Partition the new disk using fdisk command
Following command will list all detected hard disks:
# fdisk -l | grep ‘^Disk’
Output:
A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.
To partition the disk – /dev/sdb, enter:
# fdisk /dev/sdb
The basic fdisk commands you need are:
- m – print help
- p – print the partition table
- n – create a new partition
- d – delete a partition
- q – quit without saving changes
- w – write the new partition table and exit
Step#2 : Format the new disk using mkfs.ext3 command
To format Linux partitions using ext2fs on the new disk:
# mkfs.ext3 /dev/sdb1
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Step#3 : Mount the new disk using mount command
First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:
# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H
Step#4 : Update /etc/fstab file
Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:
Save and close the file.
Task: Label the partition
You can label the partition using e2label. For example, if you want to label the new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:
LABEL=/backup /disk1 ext3 defaults 1 2
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
yah thats good for understand………
i have 48TB storage server in raid 5, how do i format this server?
to format the corresponding hdd you need a RAM(Random Access Memory) 1 YB(yota byte)
1YB=1024 ZB
1ZB=1024 XB
1XB=1024 PB
1PB=1024 TB
LOL, I’ve got 1 UB (UnniByte) RAM on my Server
1UB=1024YB
1YB=1024 ZB
1ZB=1024 XB
1XB=1024 PB
1PB=1024 TB
Is it possible to format my 1.4 MB floppy now?
I have 90’90 power of per zylions! So what? You’ve only got a pint of milk. does your processor register .
Use LVM directly or read this tutorial which explains how to create partition larger than 2TB
How do I format a harddisk using linux system call
thank you fro valuable information
how to format a disk by cpp programe?is there any sample code ?
Thank you very much this valuable information.
/dev/sdb1 /disk1 ext3 defaults 1 2
The above line what is mean by defaults and what is 1 2 ?
can u explain those two things !
This is directly from the arch linux (amazing) documentation:
- The first number is “dump”: used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the entry.
- The second number is “pass”: used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 – all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method (i)Text command and
(ii)without Text command.
Hey man I also have same problem .did u got any methods to remove . please help man
verrrrrrrrry useful i’ve searched for 2 days for this thanks
Thank you very much this valuable information. Very useful this
Thanks
B. Sathish.
I have installed CentOS ..
now i want my disk to be fully formatted like a new one. with no files on it..
i remember doing it by booting in DOS mode in Win98..
Please tell how can i do it..
Thank you.
nice and clear.
Excellent and easy. Thanx
Nice information and esp. the link that you posted for Anikat. Information really useful pal. Thanks a ton..
Regards
Charanjit Singh Cheema
Thank you, this is the kind of fast reference that one is always looking for
Well, this saved me an hour of banging my head against the wall… well written! thanks!
Yes. Very useful. Thanks.
help me to see the out put of the php programe, i have php 2007 developer
Very simple and useful, thanks 🙂
Great. Searched for a long time to find this, very well done. Thanks!
Can any one tell me what the mean by 1,2 in default and when i create a raid partition is there any change in default charcter or it is sama as ” default” .
IN my Laptop both WINDOWS-XP and LINUX, i’ve safe the problem in windows hal.dll file is corrupted.
so please send to me tricks or method on Email addr.
Good Recipe for what I did in UNIX for years with the simple format command.
You boiled it down to an excellent example…
very helpfull , thanks.
very first command (fdisk /dev/sdb) failed. message is “Unable to open /dev/sdb”. any suggestions?
Is there any software to bound two NIC to use on ip address for both NICs.
Thank you very much these are very good and easy way commands to understand for the people.
how to format linex form my system plz reply solution at my email
thanks alot . that was really usefull
how many formatting for window and linux
plz sand ams on my email address
I deleted the panel in ubuntu by mistake.. how can i get the default panels?
The above steps are so good and easy to format
Thank u Very much for your Formating steps.
a very nice article. thank you for sharing.
how do installed linux …. with command . tell me all command….
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method (i)Text command and
(ii)without Text command.
Good article.
Note: this works on centos 5.5 … fyi.
This is beautiful. There are some who care out there..
IN my system both WINDOWS-XP and LINUX , I’ve installed. after that
I want to format the linux OS from my system.
so please send to me tricks or method on Email addr., so i can remove LUNUX OS from my system.
BY both method
(i)Text command and
(ii)without Text command.
Источник
How To Format USB Drive in Linux Command Line
USB formatting is the process of erasing all data from the disk and prepare it for use. Sometimes we are required to change the filesystem on our USB drive, In that case, we have to format the USB drive with the new filesystem type. Formatting a USB drive in Ubuntu using Terminal commands is much easier than formatting it in Windows systems.
This tutorial will help Ubuntu (Linux) users with the simple steps for format a USB flash drive using the command line.
Step 1 – Attach USB to System
Insert a USB drive into your system and identify your USB drive correctly. This is the step you need to take care, because you may format the wrong disk if not correctly identify your disk.
Now, You can see that the USD drive is attached as /dev/sdc1 device. Which is mounted on /media/tecadmin.
Step 2 – Format USB Drive in Linux
Whenever we attach a USB drive in Ubuntu, it is automatically mounted to the system. We can not format any disk on Linux systems that are already mounted. So first un-mount /dev/sdc1 USB drive on your system.
Now, Use one of the following commands as per the file system you want. To format a USB drive, most of the users prefer VFAT and NTFS file systems because they can be easily used on the Windows operating system.
- Format with vFat File System
- Format with NTFS File System
- Format with EXT4 File System
Similarly, you can format a USB Flash drive with any required file system.
Conclusion
In this tutorial, you have learned to format a USB drive on a Linux system via the command-line interface.
Источник
Форматирование исходного кода в Linux средствами ClangFormat: проблемы и решение
Согласитесь, приятно и полезно, когда в проекте исходный код выглядит красиво и единообразно. Это облегчает его понимание и поддержку. Покажем и расскажем, как реализовать форматирование исходного кода при помощи clang-format, git и sh.
Проблемы с форматированием и как их решить
В большинстве проектов существуют определенные правила оформления кода. Как сделать так, чтобы все участники их выполняли? На помощь приходят специальные программы — clang-format, astyle, uncrustify, — но у них есть свои недостатки.
Главная проблема форматеров состоит в том, что они меняют файлы целиком, а не только изменённые строки. Расскажем, как мы с этим справились, используя ClangFormat в рамках одного из проектов по разработке встроенного ПО для электроники, где С++ был основным языком. В команде работало несколько человек, поэтому для нас было важно обеспечить единый стиль кода. Наше решение может подойти не только программистам С++, но и тем, кто пишет код на C, Objective-C, JavaScript, Java, Protobuf.
Для форматирования мы использовали clang-format-diff-6.0. На старте запустили команду
git diff -U0 —no-color | clang-format-diff-6.0 -i -p1, но с ней возникли проблемы:
- Программа определяла типы файлов только по расширению. Например, файлы с расширением ts, которые у нас имели формат xml, воспринимала как JavaScript и падала при форматировании. Потом, она зачем-то пыталась поправить pro-файлы проектов Qt, наверное, как Protobuf.
- Программу приходилось запускать вручную, перед добавлением файлов в индекс git. Легко было об этом забыть.
Решение
В результате получился следующий sh-скрипт, запускаемый как pre-commit — хук для git:
Что делает скрипт:
GIT_DIFF=» git diff -U0 —no-color « — изменения в коде, которые подадут на вход clang-format-diff-6.0.
- -U0: обычно git diff выводит так называемый «контекст»: несколько неизменёных строк кода вокруг тех, что были изменены. Но clang-format-diff-6.0 форматирует их тоже! Поэтому контекст в данном случае не нужен.
CLANG_FORMAT=» clang-format-diff-6.0 -p1 -v -sort-includes -style=Chromium -iregex ‘.*\.(cxx|cpp|hpp|h)$’ « — команда для форматирования diff, полученного через стандартный ввод.
- clang-format-diff-6.0 — скрипт из пакета clang-format-6.0. Есть другие версии, но все тесты были только на этой.
- -p1 взят из примеров в документации, обеспечивает совместимость с выводом git diff.
- -style=Chromium — готовый пресет стиля форматирования кода. Другие возможные значения: LLVM, Google, Mozilla, WebKit.
- -sort-includes — опция сортировки по алфавиту директив #include (не обязательна).
- -iregex ‘.*\.(cxx|cpp|hpp|h)$’ — регулярное выражение, фильтрующее имена файлов по расширениям. Тут перечислены только те расширения, которые надо форматировать. Это убережёт программу от падения и неожиданных глюков. Скорее всего список нужно будет дополнить в новых проектах. Кроме С++ можно форматировать C/Objective-C/JavaScript/Java/Protobuf. Хотя эти типы файлов мы не тестировали.
GIT_APPLY=» git apply -v -p0 — « — применение к коду патча, выданного предыдущей командой.
- -p0: по умолчанию git apply пропускает первый компонент в пути к файлу, это несовместимо с форматом, который выдаёт clang-format-diff-6.0. Здесь отключено такое пропускание.
FORMATTER_DIFF=$(eval $
echo «$
eval $
Источник